Merge "Follow up to I3e28c0163dc14dacf847c5a69730ba2e29650370"

This commit is contained in:
Zuul 2019-11-05 22:27:00 +00:00 committed by Gerrit Code Review
commit 25a29d7893
2 changed files with 10 additions and 5 deletions

View File

@ -537,8 +537,9 @@ class FinishResizeAtDestTask(base.TaskBase):
fault = objects.InstanceFault.get_latest_for_instance( fault = objects.InstanceFault.get_latest_for_instance(
self.context, self.instance.uuid) self.context, self.instance.uuid)
if fault: if fault:
fault = clone_creatable_object(source_cell_context, fault) fault_clone = clone_creatable_object(source_cell_context,
fault.create() fault)
fault_clone.create()
except Exception: except Exception:
LOG.exception( LOG.exception(
'Failed to copy instance fault from target cell DB', 'Failed to copy instance fault from target cell DB',
@ -568,9 +569,10 @@ class FinishResizeAtDestTask(base.TaskBase):
# create it in the source cell DB. # create it in the source cell DB.
for event in events: for event in events:
if event.event == event_name: if event.event == event_name:
event = clone_creatable_object( event_clone = clone_creatable_object(
source_cell_context, event) source_cell_context, event)
event.create(action.instance_uuid, action.request_id) event_clone.create(action.instance_uuid,
action.request_id)
break break
else: else:
LOG.warning('Failed to find InstanceActionEvent with ' LOG.warning('Failed to find InstanceActionEvent with '

View File

@ -969,7 +969,8 @@ class FinishResizeAtDestTaskTestCase(test.TestCase):
self.assertEqual(self.target_context.cell_uuid, self.assertEqual(self.target_context.cell_uuid,
mapping.cell_mapping.uuid) mapping.cell_mapping.uuid)
def test_finish_snapshot_based_resize_at_dest_fails(self): @mock.patch('nova.objects.InstanceMapping.save')
def test_finish_snapshot_based_resize_at_dest_fails(self, mock_im_save):
"""Tests when the finish_snapshot_based_resize_at_dest compute method """Tests when the finish_snapshot_based_resize_at_dest compute method
raises an error. raises an error.
""" """
@ -994,6 +995,8 @@ class FinishResizeAtDestTaskTestCase(test.TestCase):
# copied from the target cell DB to the source cell DB. # copied from the target cell DB to the source cell DB.
copy_fault.assert_called_once_with(self.source_context) copy_fault.assert_called_once_with(self.source_context)
copy_event.assert_called_once_with(self.source_context) copy_event.assert_called_once_with(self.source_context)
# Assert the instance mapping was never updated.
mock_im_save.assert_not_called()
def test_copy_latest_fault(self): def test_copy_latest_fault(self):
"""Tests _copy_latest_fault working as expected""" """Tests _copy_latest_fault working as expected"""