Merge "Ignore VirtDriverNotReady in _sync_power_states periodic task" into stable/queens
This commit is contained in:
commit
f7cceecd53
@ -7113,7 +7113,14 @@ class ComputeManager(manager.Manager):
|
||||
expected_attrs=[],
|
||||
use_slave=True)
|
||||
|
||||
num_vm_instances = self.driver.get_num_instances()
|
||||
try:
|
||||
num_vm_instances = self.driver.get_num_instances()
|
||||
except exception.VirtDriverNotReady as e:
|
||||
# If the virt driver is not ready, like ironic-api not being up
|
||||
# yet in the case of ironic, just log it and exit.
|
||||
LOG.info('Skipping _sync_power_states periodic task due to: %s', e)
|
||||
return
|
||||
|
||||
num_db_instances = len(db_instances)
|
||||
|
||||
if num_vm_instances != num_db_instances:
|
||||
|
@ -1630,6 +1630,20 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
||||
use_slave=True)
|
||||
mock_spawn.assert_called_once_with(mock.ANY, instance)
|
||||
|
||||
@mock.patch('nova.objects.InstanceList.get_by_host', new=mock.Mock())
|
||||
@mock.patch('nova.compute.manager.ComputeManager.'
|
||||
'_query_driver_power_state_and_sync',
|
||||
new_callable=mock.NonCallableMock)
|
||||
def test_sync_power_states_virt_driver_not_ready(self, _mock_sync):
|
||||
""""Tests that the periodic task exits early if the driver raises
|
||||
VirtDriverNotReady.
|
||||
"""
|
||||
with mock.patch.object(
|
||||
self.compute.driver, 'get_num_instances',
|
||||
side_effect=exception.VirtDriverNotReady) as gni:
|
||||
self.compute._sync_power_states(mock.sentinel.context)
|
||||
gni.assert_called_once_with()
|
||||
|
||||
def _get_sync_instance(self, power_state, vm_state, task_state=None,
|
||||
shutdown_terminate=False):
|
||||
instance = objects.Instance()
|
||||
|
Loading…
Reference in New Issue
Block a user