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
This commit is contained in:
Sean McGinnis 2016-09-07 20:45:20 -05:00
parent 041b6f7a52
commit e34bc5dc5c
2 changed files with 14 additions and 0 deletions

View File

@ -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}

View File

@ -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 '