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 eedd0f6f384..393360a7372 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 @@ -618,6 +618,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 1c5bb1e0116..352fb08bc74 100644 --- a/cinder/volume/drivers/dell_emc/powermax/common.py +++ b/cinder/volume/drivers/dell_emc/powermax/common.py @@ -5218,16 +5218,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}) @@ -5235,7 +5240,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