[Pure Storage] Add missing DB values when performing create CG from

CG snap

Return the correct metadata from new volumes created after cloning
a consistency group from a snapshot.
Previously nothing was returned which causes issue with PowerVC.

Change-Id: Ia11abfe5f12aedd364fcd5ecd979733178c7dbd1
Closes-Bug: #1945824
This commit is contained in:
Simon Dodsley 2021-10-01 14:42:58 -04:00
parent 91d0a6512f
commit 35c0788377
3 changed files with 20 additions and 10 deletions

View File

@ -1679,7 +1679,7 @@ class PureBaseVolumeDriverTestCase(PureBaseSharedDriverTestCase):
mock_cgsnapshot = mock.Mock() mock_cgsnapshot = mock.Mock()
mock_snapshots = [mock.Mock() for i in range(5)] mock_snapshots = [mock.Mock() for i in range(5)]
mock_volumes = [mock.Mock() for i in range(5)] mock_volumes = [mock.Mock() for i in range(5)]
result = self.driver.create_consistencygroup_from_src( self.driver.create_consistencygroup_from_src(
mock_context, mock_context,
mock_group, mock_group,
mock_volumes, mock_volumes,
@ -1688,7 +1688,6 @@ class PureBaseVolumeDriverTestCase(PureBaseSharedDriverTestCase):
source_cg=None, source_cg=None,
source_vols=None source_vols=None
) )
self.assertEqual((None, None), result)
mock_create_cg.assert_called_with(mock_context, mock_group) mock_create_cg.assert_called_with(mock_context, mock_group)
expected_calls = [mock.call(vol, snap) expected_calls = [mock.call(vol, snap)
for vol, snap in zip(mock_volumes, mock_snapshots)] for vol, snap in zip(mock_volumes, mock_snapshots)]
@ -1715,14 +1714,13 @@ class PureBaseVolumeDriverTestCase(PureBaseSharedDriverTestCase):
mock_source_cg = mock.MagicMock() mock_source_cg = mock.MagicMock()
mock_volumes = [mock.MagicMock() for i in range(num_volumes)] mock_volumes = [mock.MagicMock() for i in range(num_volumes)]
mock_source_vols = [mock.MagicMock() for i in range(num_volumes)] mock_source_vols = [mock.MagicMock() for i in range(num_volumes)]
result = self.driver.create_consistencygroup_from_src( self.driver.create_consistencygroup_from_src(
mock_context, mock_context,
mock_group, mock_group,
mock_volumes, mock_volumes,
source_cg=mock_source_cg, source_cg=mock_source_cg,
source_vols=mock_source_vols source_vols=mock_source_vols
) )
self.assertEqual((None, None), result)
mock_create_cg.assert_called_with(mock_context, mock_group) mock_create_cg.assert_called_with(mock_context, mock_group)
self.assertTrue(self.array.create_pgroup_snapshot.called) self.assertTrue(self.array.create_pgroup_snapshot.called)
self.assertTrue(self.array.destroy_pgroup.called) self.assertTrue(self.array.destroy_pgroup.called)

View File

@ -550,6 +550,7 @@ class PureBaseVolumeDriver(san.SanDriver):
repl_status = fields.ReplicationStatus.ENABLED repl_status = fields.ReplicationStatus.ENABLED
model_update = { model_update = {
'id': volume.id,
'provider_id': purity_vol_name, 'provider_id': purity_vol_name,
'replication_status': repl_status, 'replication_status': repl_status,
} }
@ -976,8 +977,11 @@ class PureBaseVolumeDriver(san.SanDriver):
The new volumes will be consistent with the snapshot. The new volumes will be consistent with the snapshot.
""" """
vol_models = []
for volume, snapshot in zip(volumes, snapshots): for volume, snapshot in zip(volumes, snapshots):
self.create_volume_from_snapshot(volume, snapshot) vol_models.append(self.create_volume_from_snapshot(volume,
snapshot))
return vol_models
def _create_cg_from_cg(self, group, source_group, volumes, source_vols): def _create_cg_from_cg(self, group, source_group, volumes, source_vols):
"""Creates a new consistency group from an existing cg. """Creates a new consistency group from an existing cg.
@ -985,6 +989,7 @@ class PureBaseVolumeDriver(san.SanDriver):
The new volumes will be in a consistent state, but this requires The new volumes will be in a consistent state, but this requires
taking a new temporary group snapshot and cloning from that. taking a new temporary group snapshot and cloning from that.
""" """
vol_models = []
pgroup_name = self._get_pgroup_name(source_group) pgroup_name = self._get_pgroup_name(source_group)
tmp_suffix = '%s-tmp' % uuid.uuid4() tmp_suffix = '%s-tmp' % uuid.uuid4()
tmp_pgsnap_name = '%(pgroup_name)s.%(pgsnap_suffix)s' % { tmp_pgsnap_name = '%(pgroup_name)s.%(pgsnap_suffix)s' % {
@ -1013,19 +1018,21 @@ class PureBaseVolumeDriver(san.SanDriver):
) )
finally: finally:
self._delete_pgsnapshot(tmp_pgsnap_name) self._delete_pgsnapshot(tmp_pgsnap_name)
return vol_models
@pure_driver_debug_trace @pure_driver_debug_trace
def create_consistencygroup_from_src(self, context, group, volumes, def create_consistencygroup_from_src(self, context, group, volumes,
cgsnapshot=None, snapshots=None, cgsnapshot=None, snapshots=None,
source_cg=None, source_vols=None): source_cg=None, source_vols=None):
self.create_consistencygroup(context, group) model_update = self.create_consistencygroup(context, group)
if cgsnapshot and snapshots: if cgsnapshot and snapshots:
self._create_cg_from_cgsnap(volumes, vol_models = self._create_cg_from_cgsnap(volumes,
snapshots) snapshots)
elif source_cg: elif source_cg:
self._create_cg_from_cg(group, source_cg, volumes, source_vols) vol_models = self._create_cg_from_cg(group, source_cg,
volumes, source_vols)
return None, None return model_update, vol_models
@pure_driver_debug_trace @pure_driver_debug_trace
def delete_consistencygroup(self, context, group, volumes): def delete_consistencygroup(self, context, group, volumes):

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Pure Storage driver `Bug #1945824 <https://bugs.launchpad.net/cinder/+bug/1945824>`_:
Fixed missing DB values when creating new consistency group from CG snapshot.