Merge "Handle VirtDriverNotReady in _cleanup_running_deleted_instances"
This commit is contained in:
commit
7020196aaa
@ -8397,7 +8397,17 @@ class ComputeManager(manager.Manager):
|
|||||||
|
|
||||||
# NOTE(sirp): admin contexts don't ordinarily return deleted records
|
# NOTE(sirp): admin contexts don't ordinarily return deleted records
|
||||||
with utils.temporary_mutation(context, read_deleted="yes"):
|
with utils.temporary_mutation(context, read_deleted="yes"):
|
||||||
for instance in self._running_deleted_instances(context):
|
|
||||||
|
try:
|
||||||
|
instances = self._running_deleted_instances(context)
|
||||||
|
except exception.VirtDriverNotReady:
|
||||||
|
# Since this task runs immediately on startup, if the
|
||||||
|
# hypervisor is not yet ready handle it gracefully.
|
||||||
|
LOG.debug('Unable to check for running deleted instances '
|
||||||
|
'at this time since the hypervisor is not ready.')
|
||||||
|
return
|
||||||
|
|
||||||
|
for instance in instances:
|
||||||
if action == "log":
|
if action == "log":
|
||||||
LOG.warning("Detected instance with name label "
|
LOG.warning("Detected instance with name label "
|
||||||
"'%s' which is marked as "
|
"'%s' which is marked as "
|
||||||
|
@ -1925,6 +1925,19 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase,
|
|||||||
power_state.NOSTATE,
|
power_state.NOSTATE,
|
||||||
use_slave=True)
|
use_slave=True)
|
||||||
|
|
||||||
|
def test_cleanup_running_deleted_instances_virt_driver_not_ready(self):
|
||||||
|
"""Tests the scenario that the driver raises VirtDriverNotReady
|
||||||
|
when listing instances so the task returns early.
|
||||||
|
"""
|
||||||
|
self.flags(running_deleted_instance_action='shutdown')
|
||||||
|
with mock.patch.object(self.compute, '_running_deleted_instances',
|
||||||
|
side_effect=exception.VirtDriverNotReady) as ls:
|
||||||
|
# Mock the virt driver to make sure nothing calls it.
|
||||||
|
with mock.patch.object(self.compute, 'driver',
|
||||||
|
new_callable=mock.NonCallableMock):
|
||||||
|
self.compute._cleanup_running_deleted_instances(self.context)
|
||||||
|
ls.assert_called_once_with(test.MatchType(context.RequestContext))
|
||||||
|
|
||||||
@mock.patch.object(virt_driver.ComputeDriver, 'delete_instance_files')
|
@mock.patch.object(virt_driver.ComputeDriver, 'delete_instance_files')
|
||||||
@mock.patch.object(objects.InstanceList, 'get_by_filters')
|
@mock.patch.object(objects.InstanceList, 'get_by_filters')
|
||||||
def test_run_pending_deletes(self, mock_get, mock_delete):
|
def test_run_pending_deletes(self, mock_get, mock_delete):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user