From fd77dfa223a9da7428003b8e1c95f45c932f6e02 Mon Sep 17 00:00:00 2001 From: GirishChilukuri Date: Thu, 21 Jan 2021 10:22:12 +0000 Subject: [PATCH] [SVF]:Storwize hyperswap volume is not deleting. [Spectrum Virtualize Family] During hyperswap volume delete operation check_vdisk_fc_mappings is trying to delete the remote copy controlled fcmaps which are created for hyperswap volumes. This patch fixes the issue by ignoring the remote copy controlled fcmaps. Closes-Bug: #1912564 Change-Id: I98f1c60810d675a51ce1cae8bcce51c6d88e6cd2 --- .../volume/drivers/ibm/test_storwize_svc.py | 71 +++++++++++++++++++ .../ibm/storwize_svc/storwize_svc_common.py | 8 ++- ...lume-is-not-deleting-a94291248f8f59cd.yaml | 6 ++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-1912564-strowize-hyperswap-volume-is-not-deleting-a94291248f8f59cd.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 0a341a77d1c..a6a0a5fab4d 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -8932,6 +8932,77 @@ class StorwizeHelpersTestCase(test.TestCase): self.assertEqual(0, rmfcmap.call_count) self.assertEqual(0, chfcmap.call_count) + @ddt.data(([{'cp_rate': '0', 'prgs': '0', 'status': 'idle_or_copied', + 'trg_vdisk': 'vdisk', 'src_vdisk': 'Hyp_vol'}, + {'cp_rate': '50', 'prgs': '0', 'status': 'idle_or_copied', + 'trg_vdisk': 'Hyp_vol', 'src_vdisk': 'vdisk'}, + {'cp_rate': '50', 'prgs': '3', 'status': 'copying', + 'trg_vdisk': 'Snap_vol', 'src_vdisk': 'Hyp_vol'}, + {'cp_rate': '50', 'prgs': '0', 'status': 'copying', + 'trg_vdisk': 'Snap_vol_1', 'src_vdisk': 'Hyp_vol'}], 0), + ([{'cp_rate': '0', 'prgs': '0', 'status': 'idle_or_copied', + 'trg_vdisk': 'vdisk', 'src_vdisk': 'Hyp_vol'}, + {'cp_rate': '50', 'prgs': '0', 'status': 'idle_or_copied', + 'trg_vdisk': 'Hyp_vol', 'src_vdisk': 'vdisk'}, + {'cp_rate': '50', 'prgs': '100', 'status': 'copying', + 'trg_vdisk': 'Snap_vol', 'src_vdisk': 'Hyp_vol'}, + {'cp_rate': '50', 'prgs': '0', 'status': 'copying', + 'trg_vdisk': 'Snap_vol_1', 'src_vdisk': 'Hyp_vol'}], 1)) + @mock.patch.object(storwize_svc_common.StorwizeSSH, 'chfcmap') + @mock.patch.object(storwize_svc_common.StorwizeSSH, 'stopfcmap') + @mock.patch.object(storwize_svc_common.StorwizeSSH, 'rmfcmap') + @mock.patch.object(storwize_svc_common.StorwizeHelpers, + '_get_flashcopy_mapping_attributes') + @mock.patch.object(storwize_svc_common.StorwizeHelpers, + '_get_vdisk_fc_mappings') + @ddt.unpack + def test_check_vdisk_fc_mappings_rc_cont(self, + fc_data, stopfc_count, + get_vdisk_fc_mappings, + get_fc_mapping_attributes, + rmfcmap, stopfcmap, chfcmap): + vol = 'Hyp_vol' + get_vdisk_fc_mappings.return_value = ['4', '5', '7', '9'] + get_fc_mapping_attributes.side_effect = [ + { + 'copy_rate': fc_data[0]['cp_rate'], + 'progress': fc_data[0]['prgs'], + 'status': fc_data[0]['status'], + 'target_vdisk_name': fc_data[0]['trg_vdisk'], + 'rc_controlled': 'yes', + 'source_vdisk_name': fc_data[0]['src_vdisk']}, + { + 'copy_rate': fc_data[1]['cp_rate'], + 'progress': fc_data[1]['prgs'], + 'status': fc_data[1]['status'], + 'target_vdisk_name': fc_data[1]['trg_vdisk'], + 'rc_controlled': 'yes', + 'source_vdisk_name': fc_data[1]['src_vdisk']}, + { + 'copy_rate': fc_data[2]['cp_rate'], + 'progress': fc_data[2]['prgs'], + 'status': fc_data[2]['status'], + 'target_vdisk_name': fc_data[2]['trg_vdisk'], + 'rc_controlled': 'no', + 'source_vdisk_name': fc_data[2]['src_vdisk']}, + { + 'copy_rate': fc_data[3]['cp_rate'], + 'progress': fc_data[3]['prgs'], + 'status': fc_data[3]['status'], + 'target_vdisk_name': fc_data[3]['trg_vdisk'], + 'rc_controlled': 'no', + 'source_vdisk_name': fc_data[3]['src_vdisk']}] + + self.storwize_svc_common._check_vdisk_fc_mappings(vol, True, True) + get_vdisk_fc_mappings.assert_called() + get_fc_mapping_attributes.assert_called() + rmfcmap.assert_not_called() + chfcmap.assert_not_called() + self.assertEqual(4, get_fc_mapping_attributes.call_count) + self.assertEqual(stopfc_count, stopfcmap.call_count) + self.assertEqual(0, rmfcmap.call_count) + self.assertEqual(0, chfcmap.call_count) + def test_storwize_check_flashcopy_rate_invalid1(self): with mock.patch.object(storwize_svc_common.StorwizeHelpers, 'get_system_info') as get_system_info: 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 5a037738662..c26d2c07036 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -2194,6 +2194,7 @@ class StorwizeHelpers(object): """FlashCopy mapping check helper.""" # if this is a remove disk we need to be down to one fc clone mapping_ids = self._get_vdisk_fc_mappings(name) + Rc_mapping_ids = [] if len(mapping_ids) > 1 and allow_fctgt: LOG.debug('Loopcall: vdisk %s has ' 'more than one fc map. Waiting.', name) @@ -2201,6 +2202,10 @@ class StorwizeHelpers(object): attrs = self._get_flashcopy_mapping_attributes(map_id) if not attrs: continue + if 'yes' == attrs.get('rc_controlled', None): + Rc_mapping_ids.append(map_id) + continue + source = attrs['source_vdisk_name'] target = attrs['target_vdisk_name'] copy_rate = attrs['copy_rate'] @@ -2224,7 +2229,8 @@ class StorwizeHelpers(object): # next attempts in case of any cli exception. except exception.VolumeBackendAPIException as ex: LOG.warning(ex) - return + if len(mapping_ids) - len(Rc_mapping_ids) > 1: + return return self._check_delete_vdisk_fc_mappings( name, allow_snaps=allow_snaps, allow_fctgt=allow_fctgt) diff --git a/releasenotes/notes/bug-1912564-strowize-hyperswap-volume-is-not-deleting-a94291248f8f59cd.yaml b/releasenotes/notes/bug-1912564-strowize-hyperswap-volume-is-not-deleting-a94291248f8f59cd.yaml new file mode 100644 index 00000000000..6fb825cb4b0 --- /dev/null +++ b/releasenotes/notes/bug-1912564-strowize-hyperswap-volume-is-not-deleting-a94291248f8f59cd.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + IBM Spectrum Virtualize Family driver `Bug #1912564 + `_: Fixed HyperSwap + volume deletion issue.