Merge "Cells: Handle instance_destroy_at_top failure"
This commit is contained in:
commit
003a2f6fcb
@ -1053,6 +1053,20 @@ class _BroadcastMessageMethods(_BaseMessageMethods):
|
||||
instance.destroy()
|
||||
except exception.InstanceNotFound:
|
||||
pass
|
||||
except exception.ObjectActionError:
|
||||
# NOTE(alaski): instance_destroy_at_top will sometimes be called
|
||||
# when an instance does not exist in a cell but does in the parent.
|
||||
# In that case instance.id is not set which causes instance.destroy
|
||||
# to fail thinking that the object has already been destroyed.
|
||||
# That's the right assumption for it to make because without cells
|
||||
# that would be true. But for cells we'll try to pull the actual
|
||||
# instance and try to delete it again.
|
||||
try:
|
||||
instance = objects.Instance.get_by_uuid(message.ctxt,
|
||||
instance.uuid)
|
||||
instance.destroy()
|
||||
except exception.InstanceNotFound:
|
||||
pass
|
||||
|
||||
def instance_delete_everywhere(self, message, instance, delete_type,
|
||||
**kwargs):
|
||||
|
@ -1565,6 +1565,13 @@ class CellsBroadcastMethodsTestCase(test.TestCase):
|
||||
fake_instance)
|
||||
mock_destroy.assert_called_once_with()
|
||||
|
||||
def test_instance_destroy_at_top_incomplete_instance_obj(self):
|
||||
fake_instance = objects.Instance(uuid='fake_uuid')
|
||||
with mock.patch.object(objects.Instance, 'get_by_uuid') as mock_get:
|
||||
self.src_msg_runner.instance_destroy_at_top(self.ctxt,
|
||||
fake_instance)
|
||||
mock_get.assert_called_once_with(self.ctxt, fake_instance.uuid)
|
||||
|
||||
def test_instance_hard_delete_everywhere(self):
|
||||
# Reset this, as this is a broadcast down.
|
||||
self._setup_attrs(up=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user