From 8e130e2be7c2eb604d53fd6053254c6b54d47524 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 (cherry picked from commit 53c3cfa7a02d684ce27800e22e00a816af44c510) (cherry picked from commit 91282f879cb453e4baa6c6decb4fff849c7a1b2a) --- 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 fc84b1377a0a..57c6d56d841e 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -5881,9 +5881,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 46720975e3d2..2d95ba5620b6 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -2317,11 +2317,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 @@ -2463,12 +2463,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 66ef4d7b8e1c..ec8958eac654 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -325,6 +325,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