Skip to content

Commit e5c6bf1

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "compute: Ensure updates to bdms during pre_live_migration are saved" into stable/wallaby
2 parents a84083c + 9bccc5a commit e5c6bf1

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

nova/compute/manager.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8214,6 +8214,14 @@ def pre_live_migration(self, context, instance, disk, migrate_data):
82148214
self.network_api.setup_networks_on_host(context, instance,
82158215
self.host)
82168216

8217+
# NOTE(lyarwood): The above call to driver.pre_live_migration
8218+
# can result in the virt drivers attempting to stash additional
8219+
# metadata into the connection_info of the underlying bdm.
8220+
# Ensure this is saved to the database by calling .save() against
8221+
# the driver BDMs we passed down via block_device_info.
8222+
for driver_bdm in block_device_info['block_device_mapping']:
8223+
driver_bdm.save()
8224+
82178225
except Exception:
82188226
# If we raise, migrate_data with the updated attachment ids
82198227
# will not be returned to the source host for rollback.

nova/tests/functional/regressions/test_bug_1939545.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ def test_live_migrate_update_device_path(
103103
# Live migrate the instance to another host
104104
self._live_migrate(self.server)
105105

106-
# FIXME(lyarwood): This is bug #1939545, again get the volume bdm and
107-
# assert that the saved connection_info doesn't contain device_path.
106+
# Again get the volume bdm and assert that the saved connection_info
107+
# contains device_path.
108108
bdm = objects.BlockDeviceMapping.get_by_volume_and_instance(
109109
ctxt, volume_id, self.server['id'])
110110
connection_info = jsonutils.loads(bdm.connection_info)
111-
self.assertNotIn('device_path', connection_info.get('data'))
111+
self.assertIn('device_path', connection_info.get('data'))

nova/tests/unit/compute/test_compute_mgr.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9220,6 +9220,10 @@ def _test(mock_attach, mock_get_bdms, mock_ivbi,
92209220
mock_gibdi, mock_plm, mock_nwapi, mock_notify,
92219221
mock_bdm_save, mock_attach_complete, mock_notify_about_inst):
92229222

9223+
mock_driver_bdm = mock.Mock(spec=driver_bdm_volume)
9224+
mock_gibdi.return_value = {
9225+
'block_device_mapping': [mock_driver_bdm]}
9226+
92239227
mock_get_bdms.return_value = [vol_bdm, image_bdm]
92249228
mock_attach.return_value = {'id': new_attachment_id}
92259229
mock_plm.return_value = migrate_data
@@ -9244,7 +9248,10 @@ def _test(mock_attach, mock_get_bdms, mock_ivbi,
92449248
self.assertEqual(vol_bdm.attachment_id, new_attachment_id)
92459249
self.assertEqual(migrate_data.old_vol_attachment_ids[volume_id],
92469250
orig_attachment_id)
9251+
# Initially save of the attachment_id
92479252
mock_bdm_save.assert_called_once_with()
9253+
# Later save via the driver bdm for connection_info updates etc.
9254+
mock_driver_bdm.save.assert_called_once_with()
92489255
mock_attach_complete.assert_called_once_with(self.context,
92499256
new_attachment_id)
92509257

0 commit comments

Comments
 (0)