Skip to content

Commit 3b678fc

Browse files
committed
Follow up to I3e28c0163dc14dacf847c5a69730ba2e29650370
This addresses a few nits in the referenced change: * https://review.opendev.org/#/c/635646/48/nova/conductor/tasks/cross_cell_migrate.py@540 * https://review.opendev.org/#/c/635646/48/nova/conductor/tasks/cross_cell_migrate.py@571 * https://review.opendev.org/#/c/635646/48/nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py@997 Part of blueprint cross-cell-resize Change-Id: I3deb84cde1b25247cc5721d13a6a35cc8faeee46
1 parent 1989294 commit 3b678fc

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

nova/conductor/tasks/cross_cell_migrate.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,9 @@ def _copy_latest_fault(self, source_cell_context):
537537
fault = objects.InstanceFault.get_latest_for_instance(
538538
self.context, self.instance.uuid)
539539
if fault:
540-
fault = clone_creatable_object(source_cell_context, fault)
541-
fault.create()
540+
fault_clone = clone_creatable_object(source_cell_context,
541+
fault)
542+
fault_clone.create()
542543
except Exception:
543544
LOG.exception(
544545
'Failed to copy instance fault from target cell DB',
@@ -568,9 +569,10 @@ def _copy_finish_snapshot_based_resize_at_dest_event(
568569
# create it in the source cell DB.
569570
for event in events:
570571
if event.event == event_name:
571-
event = clone_creatable_object(
572+
event_clone = clone_creatable_object(
572573
source_cell_context, event)
573-
event.create(action.instance_uuid, action.request_id)
574+
event_clone.create(action.instance_uuid,
575+
action.request_id)
574576
break
575577
else:
576578
LOG.warning('Failed to find InstanceActionEvent with '

nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,8 @@ def test_execute(self):
969969
self.assertEqual(self.target_context.cell_uuid,
970970
mapping.cell_mapping.uuid)
971971

972-
def test_finish_snapshot_based_resize_at_dest_fails(self):
972+
@mock.patch('nova.objects.InstanceMapping.save')
973+
def test_finish_snapshot_based_resize_at_dest_fails(self, mock_im_save):
973974
"""Tests when the finish_snapshot_based_resize_at_dest compute method
974975
raises an error.
975976
"""
@@ -994,6 +995,8 @@ def test_finish_snapshot_based_resize_at_dest_fails(self):
994995
# copied from the target cell DB to the source cell DB.
995996
copy_fault.assert_called_once_with(self.source_context)
996997
copy_event.assert_called_once_with(self.source_context)
998+
# Assert the instance mapping was never updated.
999+
mock_im_save.assert_not_called()
9971000

9981001
def test_copy_latest_fault(self):
9991002
"""Tests _copy_latest_fault working as expected"""

0 commit comments

Comments
 (0)