diff --git a/nova/conductor/tasks/cross_cell_migrate.py b/nova/conductor/tasks/cross_cell_migrate.py index cd98cbe7a884..4fa1037d2383 100644 --- a/nova/conductor/tasks/cross_cell_migrate.py +++ b/nova/conductor/tasks/cross_cell_migrate.py @@ -537,8 +537,9 @@ class FinishResizeAtDestTask(base.TaskBase): fault = objects.InstanceFault.get_latest_for_instance( self.context, self.instance.uuid) if fault: - fault = clone_creatable_object(source_cell_context, fault) - fault.create() + fault_clone = clone_creatable_object(source_cell_context, + fault) + fault_clone.create() except Exception: LOG.exception( 'Failed to copy instance fault from target cell DB', @@ -568,9 +569,10 @@ class FinishResizeAtDestTask(base.TaskBase): # create it in the source cell DB. for event in events: if event.event == event_name: - event = clone_creatable_object( + event_clone = clone_creatable_object( source_cell_context, event) - event.create(action.instance_uuid, action.request_id) + event_clone.create(action.instance_uuid, + action.request_id) break else: LOG.warning('Failed to find InstanceActionEvent with ' diff --git a/nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py b/nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py index cc4ad3fe24cd..ed9dce8e9493 100644 --- a/nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py +++ b/nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py @@ -969,7 +969,8 @@ class FinishResizeAtDestTaskTestCase(test.TestCase): self.assertEqual(self.target_context.cell_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 raises an error. """ @@ -994,6 +995,8 @@ class FinishResizeAtDestTaskTestCase(test.TestCase): # copied from the target cell DB to the source cell DB. copy_fault.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): """Tests _copy_latest_fault working as expected"""