From 89bfc325caa86fd0af4eaa691d04e6772d55f588 Mon Sep 17 00:00:00 2001 From: asmita singh Date: Wed, 27 Feb 2019 13:40:32 +0000 Subject: [PATCH] Handle SIGHUP signal for blazar-manager correctly After a SIGHUP signal is sent to blazar-manager, the RPC messaging between API and blazar-manager stops working and users start seeing "Internal Server Error". This issue is fixed in this patch, which adds a wait method to the RPCServer class and calls the wait method of the RPC server from oslo.messaging, so that all existing requests are fulfilled before restarting the blazar-manager service again. Change-Id: I8272975afeabfb74f974e9bf9a6ae9162c22a6e0 Closes-Bug: #1807689 --- blazar/tests/manager/test_service.py | 13 +++++++++++++ blazar/utils/service.py | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/blazar/tests/manager/test_service.py b/blazar/tests/manager/test_service.py index 1d1dc23c..d12197ae 100644 --- a/blazar/tests/manager/test_service.py +++ b/blazar/tests/manager/test_service.py @@ -19,6 +19,7 @@ import ddt import eventlet import mock from oslo_config import cfg +import oslo_messaging as messaging from six.moves import reload_module from stevedore import enabled import testtools @@ -1561,3 +1562,15 @@ class ServiceTestCase(tests.TestCase): self.manager.plugins = {'physical:host': None} self.assertRaises(AttributeError, getattr, self.manager, 'physical:host:method_not_present') + + @mock.patch.object(messaging, 'get_rpc_server') + def test_rpc_server(self, mock_get_rpc_server): + server = service.ManagerService() + server.start() + for m in server.monitors: + m.start_monitoring.assert_called_once() + server.stop() + server._server.stop.assert_called_once() + server.wait() + server._server.wait.assert_called_once() + self.assertEqual(1, mock_get_rpc_server.call_count) diff --git a/blazar/utils/service.py b/blazar/utils/service.py index af36ea05..745c120a 100644 --- a/blazar/utils/service.py +++ b/blazar/utils/service.py @@ -58,6 +58,10 @@ class RPCServer(service.Service): super(RPCServer, self).start() self.tg.add_thread(self._server.start) + def wait(self): + super(RPCServer, self).wait() + self._server.wait() + def stop(self): super(RPCServer, self).stop() self._server.stop()