diff --git a/cinder/tests/unit/volume/drivers/test_gpfs.py b/cinder/tests/unit/volume/drivers/test_gpfs.py index 8d67a2dd7a0..e768c10df32 100644 --- a/cinder/tests/unit/volume/drivers/test_gpfs.py +++ b/cinder/tests/unit/volume/drivers/test_gpfs.py @@ -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 diff --git a/cinder/volume/drivers/ibm/gpfs.py b/cinder/volume/drivers/ibm/gpfs.py index 8dcead8a33d..7770d23f2a7 100644 --- a/cinder/volume/drivers/ibm/gpfs.py +++ b/cinder/volume/drivers/ibm/gpfs.py @@ -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) diff --git a/etc/cinder/rootwrap.d/volume.filters b/etc/cinder/rootwrap.d/volume.filters index 6495340549d..2bb364a8700 100644 --- a/etc/cinder/rootwrap.d/volume.filters +++ b/etc/cinder/rootwrap.d/volume.filters @@ -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