From 53c3cfa7a02d684ce27800e22e00a816af44c510 Mon Sep 17 00:00:00 2001 From: Lee Yarwood Date: Fri, 15 Feb 2019 16:26:23 +0000 Subject: [PATCH] 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 --- nova/compute/manager.py | 6 +++--- nova/tests/unit/compute/test_compute_mgr.py | 10 +++++----- nova/volume/cinder.py | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index b7fa83960aab..640b8ec61190 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -5966,9 +5966,9 @@ class ComputeManager(manager.Manager): # new style attachments (v3.44). Once we drop support for old style # attachments we could think about cleaning up the cinder-initiated # swap volume API flows. - is_cinder_migration = ( - True if old_volume['status'] in ('retyping', - 'migrating') else False) + is_cinder_migration = False + if 'migration_status' in old_volume: + is_cinder_migration = old_volume['migration_status'] == 'migrating' old_vol_size = old_volume['size'] new_volume = self.volume_api.get(context, new_volume_id) new_vol_size = new_volume['size'] diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index 462621750f32..673f37e62391 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -2336,11 +2336,11 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase, connection_info='{"data": {}}', volume_size=1) old_volume = { 'id': uuids.old_volume_id, 'size': 1, 'status': 'retyping', - 'multiattach': False + 'migration_status': 'migrating', 'multiattach': False } new_volume = { 'id': uuids.new_volume_id, 'size': 1, 'status': 'reserved', - 'multiattach': False + 'migration_status': 'migrating', 'multiattach': False } attachment_update.return_value = {"connection_info": {"data": {}}} get_bdm.return_value = bdm @@ -2482,12 +2482,12 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase, attachment_id=uuids.old_attachment_id, connection_info='{"data": {}}') old_volume = { - 'id': uuids.old_volume_id, 'size': 1, 'status': 'migrating', - 'multiattach': False + 'id': uuids.old_volume_id, 'size': 1, 'status': 'in-use', + 'migration_status': 'migrating', 'multiattach': False } new_volume = { 'id': uuids.new_volume_id, 'size': 1, 'status': 'reserved', - 'multiattach': False + 'migration_status': 'migrating', 'multiattach': False } get_bdm.return_value = bdm get_volume.side_effect = (old_volume, new_volume) diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index a17e5445c3c0..df1a58e9c57d 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -327,6 +327,9 @@ def _untranslate_volume_summary_view(context, vol): d['shared_targets'] = vol.shared_targets d['service_uuid'] = vol.service_uuid + if hasattr(vol, 'migration_status'): + d['migration_status'] = vol.migration_status + return d