From 50e173101162b32949bc51eba288c5b773cb9cb1 Mon Sep 17 00:00:00 2001 From: Mounika Sreeram Date: Tue, 2 Nov 2021 10:23:02 +0000 Subject: [PATCH] [SVF] Fix Retype issue of mirror volume [Spectrum Virtualize Family] Retype of mirror-volume to volume-type with different mirror-pool scenario is not working. When there is a change of mirror-pool in retype operation then it is checking whether source/target type has data reduction pool. If it contains data reduction pool, it will throw an exception. If not, it has to continue the retype operation with change of mirror pool. Due to the incorrect place of raising an exception for data-reduction pool,it is effecting the retype operation of volume-type with different mirror-pool. Updated the code to raise an exception correctly to fix this issue. Closes-Bug: #1949061 Change-Id: I12018c3a1f6e4e59a4923ef81da85c2d7c74e96d --- .../volume/drivers/ibm/test_storwize_svc.py | 32 +++++++++++++++++++ .../ibm/storwize_svc/storwize_svc_common.py | 2 +- ...sue_of_mirror_volume-5f37c265bee89d97.yaml | 7 ++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-1949061-ibm-svf-fix_retype_issue_of_mirror_volume-5f37c265bee89d97.yaml diff --git a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py index cd919107279..c8cd2548e27 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -7306,6 +7306,38 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): self.driver.delete_volume(vol1) + @ddt.data(({'mirror_pool': 'openstack1'}, {'mirror_pool': 'openstack2'})) + @ddt.unpack + def test_storwize_retype_from_mirror_to_different_mirror(self, + old_opts, + new_opts): + self.driver.do_setup(self.ctxt) + host = {'host': 'openstack@svc#openstack'} + ctxt = context.get_admin_context() + + vol_type1 = self._create_volume_type(old_opts, 'old') + vol_type2 = self._create_volume_type(new_opts, 'new') + diff, _equal = volume_types.volume_types_diff(ctxt, vol_type1.id, + vol_type2.id) + vol1 = self._generate_vol_info(vol_type1) + self.driver.create_volume(vol1) + + self._assert_vol_exists(vol1.name, True) + copies = self.driver._helpers.lsvdiskcopy(vol1.name) + self.assertEqual(len(copies), 2) + copies = self.driver._helpers.get_vdisk_copies(vol1.name) + self.assertEqual(copies['primary']['mdisk_grp_name'], 'openstack') + self.assertEqual(copies['secondary']['mdisk_grp_name'], 'openstack1') + + self.driver.retype(self.ctxt, vol1, vol_type2, diff, host) + copies = self.driver._helpers.lsvdiskcopy(vol1.name) + self.assertEqual(len(copies), 2) + copies = self.driver._helpers.get_vdisk_copies(vol1.name) + self.assertEqual(copies['primary']['mdisk_grp_name'], 'openstack') + self.assertEqual(copies['secondary']['mdisk_grp_name'], 'openstack2') + + self.driver.delete_volume(vol1) + @ddt.data(({}, {'mirror_pool': 'openstack1'}), ({'mirror_pool': ''}, {'mirror_pool': 'openstack1'}), ({'mirror_pool': 'openstack1'}, {}), diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index a2e95c5128a..3522983bc64 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -5190,7 +5190,7 @@ class StorwizeSVCCommonDriver(san.SanDriver, msg = _('Unable to retype: the thin-provisioned or ' 'compressed vol can not be migrated from a dr pool' ' or to a dr pool.') - raise exception.VolumeDriverException(message=msg) + raise exception.VolumeDriverException(message=msg) if not old_opts['mirror_pool'] and new_opts['mirror_pool']: need_check_dr_pool_param = True diff --git a/releasenotes/notes/bug-1949061-ibm-svf-fix_retype_issue_of_mirror_volume-5f37c265bee89d97.yaml b/releasenotes/notes/bug-1949061-ibm-svf-fix_retype_issue_of_mirror_volume-5f37c265bee89d97.yaml new file mode 100644 index 00000000000..0be7ec887a5 --- /dev/null +++ b/releasenotes/notes/bug-1949061-ibm-svf-fix_retype_issue_of_mirror_volume-5f37c265bee89d97.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + IBM Spectrum Virtualize Family driver + `Bug #1949061 `_: + Fixed retype issue of mirror-volume to mirror-volume-type + with different mirror pool