Merge "GPFS: Fix forceful delete for consistency group" into stable/ocata

This commit is contained in:
Jenkins 2017-06-06 22:39:54 +00:00 committed by Gerrit Code Review
commit 6fe2794c3a
3 changed files with 53 additions and 17 deletions

View File

@ -1667,11 +1667,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

View File

@ -1160,29 +1160,41 @@ 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('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('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('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('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('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'
@ -1244,7 +1256,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)

View File

@ -165,6 +165,7 @@ mmunlinkfileset: CommandFilter, /usr/lpp/mmfs/bin/mmunlinkfileset, root
mmdelfileset: CommandFilter, /usr/lpp/mmfs/bin/mmdelfileset, root
mmcrsnapshot: CommandFilter, /usr/lpp/mmfs/bin/mmcrsnapshot, root
mmdelsnapshot: CommandFilter, /usr/lpp/mmfs/bin/mmdelsnapshot, root
mmlsfileset: CommandFilter, /usr/lpp/mmfs/bin/mmlsfileset, root
# cinder/volume/drivers/ibm/gpfs.py
# cinder/volume/drivers/ibm/ibmnas.py