From 88d3005df43e00ac2d93b70be5bc696b1ad3a275 Mon Sep 17 00:00:00 2001 From: Venkata Krishna Date: Fri, 24 Sep 2021 14:00:02 +0000 Subject: [PATCH] [SVf] update rccg name property to metadata [Spectrum Virtualize family] While creating a group either from source_group or group_snapshot, the resulted group-volumes metadata is not updated with the rccg_name attribute. This is happening due to the order of some function calls to update volume metadata. Providing a fix to update rccg_name property to volume metadata which could cover all the possible cases like add a volume to the group, create a group from source_group and create a group from group_snapshot. Closes-Bug: #1943682 Change-Id: I0bfb79db4f69c0705a1e0fa971376d14c232d5cb --- .../volume/drivers/ibm/test_storwize_svc.py | 18 ++++++++------ .../ibm/storwize_svc/storwize_svc_common.py | 24 ++++++++++++------- ...-clone-group-volumes-baa6bebcf8caacb8.yaml | 7 ++++++ 3 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 releasenotes/notes/bug-1943682-ibm-svf-update-rccgname-to-metadata-for-clone-group-volumes-baa6bebcf8caacb8.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 95d23a58ad5..6898643a01f 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -13849,7 +13849,8 @@ class StorwizeSVCReplicationTestCase(test.TestCase): 'create_rccg')) as create_rccg: with ((mock.patch.object( storwize_svc_common.StorwizeSVCCommonDriver, - 'update_group'))) as update_group: + '_update_replication_grp'))) as update_rep_group: + update_rep_group.return_value = (dict(), dict(), dict()) # Create group from source group model_update, volumes_model_update = ( self.driver.create_group_from_src(self.ctxt, @@ -13859,8 +13860,8 @@ class StorwizeSVCReplicationTestCase(test.TestCase): src_volumes)) create_rccg.assert_called() self.assertEqual(1, create_rccg.call_count) - update_group.assert_called() - self.assertEqual(1, update_group.call_count) + update_rep_group.assert_called() + self.assertEqual(1, update_rep_group.call_count) model_update = self.driver.delete_group( self.ctxt, clone_group, [clone_vol1, clone_vol2]) self.assertEqual(fields.GroupStatus.DELETED, @@ -13964,8 +13965,11 @@ class StorwizeSVCReplicationTestCase(test.TestCase): model_update['status'], "CG create from src created passed") + rccg_name = self.driver._get_rccg_name(clone_group) for each_vol in volumes_model_update: self.assertEqual('available', each_vol['status']) + self.assertEqual(rccg_name, + each_vol['metadata']['Consistency Group Name']) model_update = self.driver.delete_group(self.ctxt, clone_group, [clone_vol1, clone_vol2]) @@ -13975,8 +13979,8 @@ class StorwizeSVCReplicationTestCase(test.TestCase): 'create_rccg')) as create_rccg: with ((mock.patch.object( storwize_svc_common.StorwizeSVCCommonDriver, - 'update_group'))) as update_group: - + '_update_replication_grp'))) as update_rep_group: + update_rep_group.return_value = (dict(), dict(), dict()) # Create group from source as group snapshot model_update, volumes_model_update = ( self.driver.create_group_from_src(self.ctxt, @@ -13987,8 +13991,8 @@ class StorwizeSVCReplicationTestCase(test.TestCase): None)) create_rccg.assert_called() self.assertEqual(1, create_rccg.call_count) - update_group.assert_called() - self.assertEqual(1, update_group.call_count) + update_rep_group.assert_called() + self.assertEqual(1, update_rep_group.call_count) model_update = ( self.driver.delete_group(self.ctxt, clone_group, 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 0fc5d8524e0..8cacc4c15a9 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -6081,16 +6081,20 @@ class StorwizeSVCCommonDriver(san.SanDriver, for vol in volumes: rep_type = self._get_volume_replicated_type(context, vol) + volume_model = dict() + for model in volumes_model: + if vol.id == model["id"]: + volume_model = model + break if rep_type: replica_obj = self._get_replica_obj(rep_type) replica_obj.volume_replication_setup(context, vol) - volumes_model[volumes.index(vol)]['replication_status'] = ( + volume_model['replication_status'] = ( fields.ReplicationStatus.ENABLED) # Updating replication properties for a volume with replication # enabled. - volumes_model[volumes.index(vol)] = ( - self._update_replication_properties( - context, vol, volumes_model[volumes.index(vol)])) + self._update_replication_properties(context, vol, + volume_model) opts = self._get_vdisk_params(vol['volume_type_id'], volume_metadata= @@ -6099,9 +6103,7 @@ class StorwizeSVCCommonDriver(san.SanDriver, # Updating QoS properties for a volume self._helpers.add_vdisk_qos(vol['name'], opts['qos'], vol['size']) - volumes_model[volumes.index(vol)] = ( - self._qos_model_update( - volumes_model[volumes.index(vol)], vol)) + self._qos_model_update(volume_model, vol) if is_hyper_group: self._helpers.ensure_vdisk_no_fc_mappings(vol['name'], @@ -6116,8 +6118,12 @@ class StorwizeSVCCommonDriver(san.SanDriver, if volume_utils.is_group_a_type( group, "consistent_group_replication_enabled"): - self.update_group(context, group, add_volumes=volumes, - remove_volumes=[]) + model_update, added_vols, removed_vols = ( + self._update_replication_grp(context, group, volumes, [])) + if model_update.get('status') != fields.GroupStatus.ERROR: + # Updating RCCG property to volume metadata + for model in volumes_model: + model['metadata']['Consistency Group Name'] = rccg_name LOG.debug("Leave: create_group_from_src.") return model_update, volumes_model diff --git a/releasenotes/notes/bug-1943682-ibm-svf-update-rccgname-to-metadata-for-clone-group-volumes-baa6bebcf8caacb8.yaml b/releasenotes/notes/bug-1943682-ibm-svf-update-rccgname-to-metadata-for-clone-group-volumes-baa6bebcf8caacb8.yaml new file mode 100644 index 00000000000..bc60990716e --- /dev/null +++ b/releasenotes/notes/bug-1943682-ibm-svf-update-rccgname-to-metadata-for-clone-group-volumes-baa6bebcf8caacb8.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + IBM Spectrum Virtualize family driver + `Bug #1943682 `_: + Updating rccg_name property to volume metadata for the resultant + volumes of a clone_group from a source_group or a group_snapshot.