Ignore InstanceNotFound exception when host rejoin cluster
Nova-compute would start failed if there are instances which were evacuated and then deleted. This patch ignores such exception. Change-Id: Ibfe17ed800edd1631c580b47f6236a7229455b4f Closes-Bug: #1897716
This commit is contained in:
parent
20ca7c4337
commit
fbf6178762
|
@ -19655,6 +19655,30 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
mock_delete_vtpm.assert_called_once_with('ctxt', fake_inst)
|
||||
mock_undefine.assert_called_once_with(fake_inst)
|
||||
|
||||
@mock.patch('nova.virt.libvirt.driver.LibvirtDriver._undefine_domain')
|
||||
@mock.patch('nova.crypto.delete_vtpm_secret')
|
||||
@mock.patch('nova.virt.libvirt.driver.LibvirtDriver.delete_instance_files')
|
||||
@mock.patch('nova.virt.driver.block_device_info_get_mapping')
|
||||
@mock.patch('nova.virt.libvirt.driver.LibvirtDriver._unplug_vifs')
|
||||
@mock.patch('nova.virt.libvirt.driver.LibvirtDriver._get_vpmems',
|
||||
new=mock.Mock(return_value=None))
|
||||
def test_cleanup_instance_marked_deleted(
|
||||
self, mock_unplug, mock_get_mapping, mock_delete_files,
|
||||
mock_delete_vtpm, mock_undefine,
|
||||
):
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI())
|
||||
fake_inst = objects.Instance(**self.test_instance)
|
||||
|
||||
fake_inst.vm_state = vm_states.DELETED
|
||||
fake_inst.deleted = True
|
||||
|
||||
with mock.patch.object(fake_inst, 'save') as instance_save:
|
||||
instance_save.side_effect = exception.InstanceNotFound(
|
||||
instance_id=uuids.instance)
|
||||
drvr.cleanup('ctxt', fake_inst, 'netinfo')
|
||||
mock_delete_vtpm.assert_called_once_with('ctxt', fake_inst)
|
||||
mock_undefine.assert_called_once_with(fake_inst)
|
||||
|
||||
@mock.patch.object(libvirt_driver.LibvirtDriver, 'delete_instance_files',
|
||||
return_value=True)
|
||||
@mock.patch.object(objects.Instance, 'save')
|
||||
|
|
|
@ -1413,7 +1413,10 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
instance.system_metadata['clean_attempts'] = str(attempts + 1)
|
||||
if success:
|
||||
instance.cleaned = True
|
||||
instance.save()
|
||||
try:
|
||||
instance.save()
|
||||
except exception.InstanceNotFound:
|
||||
pass
|
||||
|
||||
if cleanup_instance_disks:
|
||||
crypto.delete_vtpm_secret(context, instance)
|
||||
|
|
Loading…
Reference in New Issue