GPFS: Fix forceful delete for consistency group
This patch fix the force delete for a consistency group when the backend object (fileset) doesn't exist. Change-Id: I81c4fc8fd913be11d88dcbcdd38dde88144af8bd Closes-bug: #1694189
This commit is contained in:
parent
77d17a1f8b
commit
49932bbd34
@ -1628,11 +1628,34 @@ class GPFSDriverTestCase(test.TestCase):
|
||||
self.driver.delete_consistencygroup(ctxt, group, [])
|
||||
fsdev = self.driver._gpfs_device
|
||||
cgname = "consisgroup-%s" % group['id']
|
||||
cmd = ['mmlsfileset', fsdev, cgname]
|
||||
mock_exec.assert_any_call(*cmd)
|
||||
cmd = ['mmunlinkfileset', fsdev, cgname, '-f']
|
||||
mock_exec.assert_any_call(*cmd)
|
||||
cmd = ['mmdelfileset', fsdev, cgname, '-f']
|
||||
mock_exec.assert_any_call(*cmd)
|
||||
|
||||
@mock.patch('cinder.utils.execute')
|
||||
def test_delete_consistencygroup_no_fileset(self, mock_exec):
|
||||
ctxt = self.context
|
||||
group = self._fake_group()
|
||||
group['status'] = fields.ConsistencyGroupStatus.AVAILABLE
|
||||
volume = self._fake_volume()
|
||||
volume['status'] = 'available'
|
||||
volumes = []
|
||||
volumes.append(volume)
|
||||
self.driver.db = mock.Mock()
|
||||
self.driver.db.volume_get_all_by_group = mock.Mock()
|
||||
self.driver.db.volume_get_all_by_group.return_value = volumes
|
||||
mock_exec.side_effect = (
|
||||
processutils.ProcessExecutionError(exit_code=2))
|
||||
|
||||
self.driver.delete_consistencygroup(ctxt, group, [])
|
||||
fsdev = self.driver._gpfs_device
|
||||
cgname = "consisgroup-%s" % group['id']
|
||||
cmd = ['mmlsfileset', fsdev, cgname]
|
||||
mock_exec.assert_called_once_with(*cmd)
|
||||
|
||||
@mock.patch('cinder.utils.execute')
|
||||
def test_delete_consistencygroup_fail(self, mock_exec):
|
||||
ctxt = self.context
|
||||
|
@ -1163,31 +1163,43 @@ class GPFSDriver(driver.CloneableImageVD,
|
||||
"""Delete consistency group of GPFS volumes."""
|
||||
cgname = "consisgroup-%s" % group['id']
|
||||
fsdev = self._gpfs_device
|
||||
delete_fileset = True
|
||||
|
||||
model_update = {}
|
||||
model_update['status'] = group['status']
|
||||
|
||||
try:
|
||||
self.gpfs_execute(self.GPFS_PATH + 'mmlsfileset', fsdev, cgname)
|
||||
except processutils.ProcessExecutionError as e:
|
||||
if e.exit_code == 2:
|
||||
msg = (_('The fileset associated with consistency group '
|
||||
'%(cgname)s does not exist') %
|
||||
{'cgname': cgname})
|
||||
LOG.info(msg)
|
||||
delete_fileset = False
|
||||
|
||||
# Unlink and delete the fileset associated with the consistency group.
|
||||
# All of the volumes and volume snapshot data will also be deleted.
|
||||
try:
|
||||
self.gpfs_execute(self.GPFS_PATH + 'mmunlinkfileset', fsdev,
|
||||
cgname, '-f')
|
||||
except processutils.ProcessExecutionError as e:
|
||||
msg = (_('Failed to unlink fileset for consistency group '
|
||||
'%(cgname)s. Error: %(excmsg)s.') %
|
||||
{'cgname': cgname, 'excmsg': six.text_type(e)})
|
||||
LOG.error(msg)
|
||||
raise exception.VolumeBackendAPIException(data=msg)
|
||||
if delete_fileset:
|
||||
try:
|
||||
self.gpfs_execute(self.GPFS_PATH + 'mmunlinkfileset', fsdev,
|
||||
cgname, '-f')
|
||||
except processutils.ProcessExecutionError as e:
|
||||
msg = (_('Failed to unlink fileset for consistency group '
|
||||
'%(cgname)s. Error: %(excmsg)s.') %
|
||||
{'cgname': cgname, 'excmsg': six.text_type(e)})
|
||||
LOG.error(msg)
|
||||
raise exception.VolumeBackendAPIException(data=msg)
|
||||
|
||||
try:
|
||||
self.gpfs_execute(self.GPFS_PATH + 'mmdelfileset', fsdev, cgname,
|
||||
'-f')
|
||||
except processutils.ProcessExecutionError as e:
|
||||
msg = (_('Failed to delete fileset for consistency group '
|
||||
'%(cgname)s. Error: %(excmsg)s.') %
|
||||
{'cgname': cgname, 'excmsg': six.text_type(e)})
|
||||
LOG.error(msg)
|
||||
raise exception.VolumeBackendAPIException(data=msg)
|
||||
try:
|
||||
self.gpfs_execute(self.GPFS_PATH + 'mmdelfileset',
|
||||
fsdev, cgname, '-f')
|
||||
except processutils.ProcessExecutionError as e:
|
||||
msg = (_('Failed to delete fileset for consistency group '
|
||||
'%(cgname)s. Error: %(excmsg)s.') %
|
||||
{'cgname': cgname, 'excmsg': six.text_type(e)})
|
||||
LOG.error(msg)
|
||||
raise exception.VolumeBackendAPIException(data=msg)
|
||||
|
||||
for volume_ref in volumes:
|
||||
volume_ref['status'] = 'deleted'
|
||||
@ -1249,7 +1261,7 @@ class GPFSDriver(driver.CloneableImageVD,
|
||||
def create_consistencygroup_from_src(self, context, group, volumes,
|
||||
cgsnapshot=None, snapshots=None,
|
||||
source_cg=None, source_vols=None):
|
||||
msg = _('Creating a consistency group from any source consistency'
|
||||
msg = _('Creating a consistency group from any source consistency '
|
||||
'group or consistency group snapshot is not supported.')
|
||||
LOG.error(msg)
|
||||
raise exception.GPFSDriverUnsupportedOperation(msg=msg)
|
||||
|
@ -162,6 +162,7 @@ mmlsfs: CommandFilter, mmlsfs, root
|
||||
mmlspool: CommandFilter, mmlspool, root
|
||||
mkfs: CommandFilter, mkfs, root
|
||||
mmcrfileset: CommandFilter, mmcrfileset, root
|
||||
mmlsfileset: CommandFilter, mmlsfileset, root
|
||||
mmlinkfileset: CommandFilter, mmlinkfileset, root
|
||||
mmunlinkfileset: CommandFilter, mmunlinkfileset, root
|
||||
mmdelfileset: CommandFilter, mmdelfileset, root
|
||||
|
Loading…
Reference in New Issue
Block a user