Refresh target cell instance after finish_snapshot_based_resize_at_dest
FinishResizeAtDestTask needs to refresh its local copy of the target cell instance after finish_snapshot_based_resize_at_dest to make sure it has the latest copy of the instance before updating it in _update_instance_mapping otherwise if the instance is dirty conductor could overwrite fields set by the compute, like the flavor. Part of blueprint cross-cell-resize Change-Id: If6e1acb0efe1d7bac460deff2d9572ef7170f79d
This commit is contained in:
parent
f1ac153b03
commit
85a1ac12e7
@ -513,6 +513,9 @@ class FinishResizeAtDestTask(base.TaskBase):
|
||||
self.compute_rpcapi.finish_snapshot_based_resize_at_dest(
|
||||
self.context, self.instance, self.migration, self.snapshot_id,
|
||||
self.request_spec)
|
||||
# finish_snapshot_based_resize_at_dest updates the target cell
|
||||
# instance so we need to refresh it here to have the latest copy.
|
||||
self.instance.refresh()
|
||||
except Exception:
|
||||
# We need to mimic the error handlers on
|
||||
# finish_snapshot_based_resize_at_dest in the destination compute
|
||||
|
@ -949,20 +949,25 @@ class FinishResizeAtDestTaskTestCase(test.TestCase):
|
||||
|
||||
def test_execute(self):
|
||||
"""Tests the happy path scenario for the task execution."""
|
||||
with mock.patch.object(
|
||||
with test.nested(
|
||||
mock.patch.object(
|
||||
self.task.compute_rpcapi,
|
||||
'finish_snapshot_based_resize_at_dest') as finish_resize:
|
||||
'finish_snapshot_based_resize_at_dest'),
|
||||
mock.patch.object(self.task.instance, 'refresh')
|
||||
) as (
|
||||
finish_resize, refresh
|
||||
):
|
||||
self.task.execute()
|
||||
# _finish_snapshot_based_resize_at_dest will set the instance
|
||||
# task_state to resize_migrated, save the change, and call the
|
||||
# finish_snapshot_based_resize_at_dest method.
|
||||
target_instance = self.task.instance
|
||||
target_instance.refresh()
|
||||
self.assertEqual(task_states.RESIZE_MIGRATED,
|
||||
self.task.instance.task_state)
|
||||
finish_resize.assert_called_once_with(
|
||||
self.task.context, target_instance, self.task.migration,
|
||||
self.task.snapshot_id, self.task.request_spec)
|
||||
refresh.assert_called_once_with()
|
||||
# _update_instance_mapping will swap the hidden fields and update
|
||||
# the instance mapping to point at the target cell.
|
||||
self.assertFalse(target_instance.hidden,
|
||||
|
Loading…
x
Reference in New Issue
Block a user