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
This commit is contained in:
asmita singh 2019-02-27 13:40:32 +00:00 committed by Pierre Riteau
parent d9d61f12c3
commit 89bfc325ca
2 changed files with 17 additions and 0 deletions

View File

@ -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)

View File

@ -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()