Merge "Fix conductor deregistration on non init conductor"
This commit is contained in:
commit
8e4febe87b
@ -327,6 +327,10 @@ class ConductorManager(periodic_task.PeriodicTasks):
|
||||
self.add_periodic_task(method)
|
||||
|
||||
def del_host(self, deregister=True):
|
||||
# Conductor deregistration fails if called on non-initialized
|
||||
# conductor (e.g. when rpc server is unreachable).
|
||||
if not hasattr(self, 'conductor'):
|
||||
return
|
||||
self._keepalive_evt.set()
|
||||
if deregister:
|
||||
try:
|
||||
|
@ -211,6 +211,11 @@ class StartStopTestCase(_ServiceSetUpMixin, tests_db_base.DbTestCase):
|
||||
res = objects.Conductor.get_by_hostname(self.context, self.hostname)
|
||||
self.assertEqual(self.hostname, res['hostname'])
|
||||
|
||||
@mock.patch.object(manager.ConductorManager, 'init_host')
|
||||
def test_stop_uninitialized_conductor(self, mock_init):
|
||||
self._start_service()
|
||||
self.service.del_host()
|
||||
|
||||
@mock.patch.object(driver_factory.DriverFactory, '__getitem__',
|
||||
lambda *args: mock.MagicMock())
|
||||
def test_start_registers_driver_names(self):
|
||||
|
Loading…
Reference in New Issue
Block a user