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
This commit is contained in:
odonos12 2020-07-24 12:43:26 +01:00
parent 2124f39f9d
commit d4236cf865
2 changed files with 23 additions and 5 deletions

View File

@ -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',

View File

@ -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