From e34bc5dc5c6d2a97f695523751f547709f6aa5e6 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Wed, 7 Sep 2016 20:45:20 -0500 Subject: [PATCH] Eqlx: Ignore missing snapshot on delete The eqlx driver would fail if requested to delete a snapshot that no longer exists on the array. This should be ignored and return success since it is in the desired state. Change-Id: I4d1d8fa7579b22629b2cafa3fad7d0d080c849ed Closes-bug: #1480377 --- cinder/tests/unit/volume/drivers/test_eqlx.py | 11 +++++++++++ cinder/volume/drivers/eqlx.py | 3 +++ 2 files changed, 14 insertions(+) diff --git a/cinder/tests/unit/volume/drivers/test_eqlx.py b/cinder/tests/unit/volume/drivers/test_eqlx.py index 67863435edb..e02b7c12785 100644 --- a/cinder/tests/unit/volume/drivers/test_eqlx.py +++ b/cinder/tests/unit/volume/drivers/test_eqlx.py @@ -238,6 +238,17 @@ class DellEQLSanISCSIDriverTestCase(test.TestCase): mock_eql_execute.configure_mock(**mock_attrs) self.driver.delete_snapshot(snapshot) + def test_delete_absent_snapshot(self): + snapshot = {'name': 'fakesnap', 'volume_name': 'fakevolume_name'} + mock_attrs = {'args': ['volume', 'select', snapshot['volume_name'], + 'snapshot', 'delete', snapshot['name']]} + with mock.patch.object(self.driver, + '_eql_execute') as mock_eql_execute: + mock_eql_execute.configure_mock(**mock_attrs) + mock_eql_execute.side_effect = processutils.ProcessExecutionError( + stdout='% Error ..... does not exist.\n') + self.driver.delete_snapshot(snapshot) + def test_extend_volume(self): new_size = '200' volume = {'name': self.volume_name, 'size': 100} diff --git a/cinder/volume/drivers/eqlx.py b/cinder/volume/drivers/eqlx.py index 4e2f24a6b3c..9507c4b9a3c 100644 --- a/cinder/volume/drivers/eqlx.py +++ b/cinder/volume/drivers/eqlx.py @@ -566,6 +566,9 @@ class DellEQLSanISCSIDriver(san.SanISCSIDriver): try: self._eql_execute('volume', 'select', snapshot['volume_name'], 'snapshot', 'delete', snapshot['name']) + except processutils.ProcessExecutionError as err: + if err.stdout.find('does not exist') > -1: + LOG.debug('Snapshot %s could not be found.', snapshot['name']) except Exception: with excutils.save_and_reraise_exception(): LOG.error(_LE('Failed to delete snapshot %(snap)s of '