Skip to content

Commit 8e130e2

Browse files
committed
Use migration_status during volume migrating and retyping
When swapping volumes Nova has to identify if the swap itself is related to an underlying migration or retype of the volume by Cinder. Nova would previously use the status of the volume to determine if the volume was retyping or migrating. However in the migration case where a volume is moved directly between hosts the volume is never given a status of migrating by Cinder leading to Nova never calling the os-migrate_volume_completion cinder API to complete the migration. This change switches Nova to use the migration_status of the volume to ensure that this API is called for both retypes and migrations. Depends-On: https://review.openstack.org/#/c/639331/ Change-Id: I1bdf3431bda2da98380e0dcaa9f952e6768ca3af Closes-bug: #1803961 (cherry picked from commit 53c3cfa) (cherry picked from commit 91282f8)
1 parent 786083c commit 8e130e2

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

nova/compute/manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5881,9 +5881,9 @@ def swap_volume(self, context, old_volume_id, new_volume_id, instance,
58815881
# new style attachments (v3.44). Once we drop support for old style
58825882
# attachments we could think about cleaning up the cinder-initiated
58835883
# swap volume API flows.
5884-
is_cinder_migration = (
5885-
True if old_volume['status'] in ('retyping',
5886-
'migrating') else False)
5884+
is_cinder_migration = False
5885+
if 'migration_status' in old_volume:
5886+
is_cinder_migration = old_volume['migration_status'] == 'migrating'
58875887
old_vol_size = old_volume['size']
58885888
new_volume = self.volume_api.get(context, new_volume_id)
58895889
new_vol_size = new_volume['size']

nova/tests/unit/compute/test_compute_mgr.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,11 +2317,11 @@ def test_swap_volume_with_new_attachment_id_cinder_migrate_true(
23172317
connection_info='{"data": {}}', volume_size=1)
23182318
old_volume = {
23192319
'id': uuids.old_volume_id, 'size': 1, 'status': 'retyping',
2320-
'multiattach': False
2320+
'migration_status': 'migrating', 'multiattach': False
23212321
}
23222322
new_volume = {
23232323
'id': uuids.new_volume_id, 'size': 1, 'status': 'reserved',
2324-
'multiattach': False
2324+
'migration_status': 'migrating', 'multiattach': False
23252325
}
23262326
attachment_update.return_value = {"connection_info": {"data": {}}}
23272327
get_bdm.return_value = bdm
@@ -2463,12 +2463,12 @@ def test_swap_volume_with_new_attachment_id_attachment_update_fails(
24632463
attachment_id=uuids.old_attachment_id,
24642464
connection_info='{"data": {}}')
24652465
old_volume = {
2466-
'id': uuids.old_volume_id, 'size': 1, 'status': 'migrating',
2467-
'multiattach': False
2466+
'id': uuids.old_volume_id, 'size': 1, 'status': 'in-use',
2467+
'migration_status': 'migrating', 'multiattach': False
24682468
}
24692469
new_volume = {
24702470
'id': uuids.new_volume_id, 'size': 1, 'status': 'reserved',
2471-
'multiattach': False
2471+
'migration_status': 'migrating', 'multiattach': False
24722472
}
24732473
get_bdm.return_value = bdm
24742474
get_volume.side_effect = (old_volume, new_volume)

nova/volume/cinder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ def _untranslate_volume_summary_view(context, vol):
325325
d['shared_targets'] = vol.shared_targets
326326
d['service_uuid'] = vol.service_uuid
327327

328+
if hasattr(vol, 'migration_status'):
329+
d['migration_status'] = vol.migration_status
330+
328331
return d
329332

330333

0 commit comments

Comments
 (0)