From 873214b6e2d8f206ba4a2750e911998c2000745a Mon Sep 17 00:00:00 2001 From: Surojit Pathak Date: Wed, 6 Jan 2016 19:30:10 +0000 Subject: [PATCH] Fix socket descriptor leak The connection to amqp was not getting cleaned up, even after the communication to conductor across amqp was complete, for a given request. Thus, sockets were leaking with each communication and finally led to a hang situation, where no more fds were available. Change-Id: I1deabdbce6ba448fe4c25d7694aabe5e5fec7b5a Closes-Bug: #1510776 --- magnum/api/hooks.py | 3 +++ magnum/common/rpc_service.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/magnum/api/hooks.py b/magnum/api/hooks.py index ca907ef2f0..52e5d9e3c3 100644 --- a/magnum/api/hooks.py +++ b/magnum/api/hooks.py @@ -81,6 +81,9 @@ class RPCHook(hooks.PecanHook): def before(self, state): state.request.rpcapi = conductor_api.API(context=state.request.context) + def after(self, state): + state.request.rpcapi = None + class NoExceptionTracebackHook(hooks.PecanHook): """Workaround rpc.common: deserialize_remote_exception. diff --git a/magnum/common/rpc_service.py b/magnum/common/rpc_service.py index 152f51b78b..0dc8898f9f 100644 --- a/magnum/common/rpc_service.py +++ b/magnum/common/rpc_service.py @@ -106,6 +106,9 @@ class API(object): serializer=serializer, timeout=timeout) + def __del__(self): + self._client.transport.cleanup() + def _call(self, method, *args, **kwargs): return self._client.call(self._context, method, *args, **kwargs)