From d4236cf8655e8bf0845863929858502e4e3faa24 Mon Sep 17 00:00:00 2001 From: odonos12 Date: Fri, 24 Jul 2020 12:43:26 +0100 Subject: [PATCH] PowerMax Driver - Failover group vol update fix Replicated volumes that were in groups during failover do not have their model_updates saved upon return to manager.py as the replicated_vols list that is used to determine which volume should be updated is changes during _populate_volume_and_group_update_lists. Change-Id: I03efee569c7f7efec20a04755d6e7c7a60bf61ea Closes-Bug: 1888831 --- .../powermax/test_powermax_replication.py | 13 +++++++++++++ cinder/volume/drivers/dell_emc/powermax/common.py | 15 ++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_replication.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_replication.py index 90ebb6d1654..eff91a4c3f1 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_replication.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_replication.py @@ -360,6 +360,19 @@ class PowerMaxReplicationTest(test.TestCase): self.assertEqual(ref_vol_update, vols_model_update[0]) + @mock.patch.object(common.PowerMaxCommon, '_initial_setup', + return_value=tpd.PowerMaxData.extra_specs) + def test_populate_volume_and_group_update_lists_group_update_vol_list( + self, mck_setup): + volume = deepcopy(self.data.test_volume) + volume.group_id = self.data.test_group.id + volumes = [volume] + groups = [self.data.test_group] + volume_updates, group_updates = ( + self.common._populate_volume_and_group_update_lists( + volumes, groups, None)) + self.assertEqual([volume], volumes) + @mock.patch.object( utils.PowerMaxUtils, 'validate_non_replication_group_config') @mock.patch.object(volume_utils, 'is_group_a_cg_snapshot_type', diff --git a/cinder/volume/drivers/dell_emc/powermax/common.py b/cinder/volume/drivers/dell_emc/powermax/common.py index a31458c0273..8902b8659ee 100644 --- a/cinder/volume/drivers/dell_emc/powermax/common.py +++ b/cinder/volume/drivers/dell_emc/powermax/common.py @@ -4850,16 +4850,21 @@ class PowerMaxCommon(object): """ volume_update_list = [] group_update_list = [] + # Since we are updating volumes if a volume is in a group, copy to + # a new variable otherwise we will be updating the replicated_vols + # variable assigned in manager.py's failover method. + vols = deepcopy(volumes) if groups: for group in groups: - vol_list = [] - for index, vol in enumerate(volumes): + group_vol_list = [] + for index, vol in enumerate(vols): if vol.group_id == group.id: - vol_list.append(volumes.pop(index)) + group_vol_list.append(vols[index]) + vols = [vol for vol in vols if vol not in group_vol_list] grp_update, vol_updates = ( self.failover_replication( - None, group, vol_list, group_fo, host=True)) + None, group, group_vol_list, group_fo, host=True)) group_update_list.append({'group_id': group.id, 'updates': grp_update}) @@ -4867,7 +4872,7 @@ class PowerMaxCommon(object): non_rep_vol_list, sync_vol_dict, async_vol_dict, metro_vol_list = ( [], {}, {}, []) - for volume in volumes: + for volume in vols: array = ast.literal_eval(volume.provider_location)['array'] extra_specs = self._initial_setup(volume) extra_specs[utils.ARRAY] = array