Merge "Fix conductor deregistration on non init conductor"

This commit is contained in:
Jenkins 2015-10-05 18:32:44 +00:00 committed by Gerrit Code Review
commit 8e4febe87b
2 changed files with 9 additions and 0 deletions

View File

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

View File

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