Don't fail when deleting missing backup
The problem here is sometimes when the path doesn't exist and we try to delete it then exception occurs & breaks the flow. In this case it happens with the volume delete flow, wherein the exception occurs just before the quota commit & commit doesn't happen even though the backup volume got deleted, hence catching the exception just where it occurs. Change-Id: I8713f846b1e2e30b4bbc4af57645fdc04bcd8386 Closes-Bug: 1726715
This commit is contained in:
parent
859d3ac945
commit
6ff364f385
@ -127,7 +127,10 @@ class PosixBackupDriver(chunkeddriver.ChunkedBackupDriver):
|
||||
def delete_object(self, container, object_name):
|
||||
# TODO(tbarron): clean up the container path if it is empty
|
||||
path = os.path.join(self.backup_path, container, object_name)
|
||||
try:
|
||||
os.remove(path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def _generate_object_name_prefix(self, backup):
|
||||
timestamp = timeutils.utcnow().strftime("%Y%m%d%H%M%S")
|
||||
|
@ -170,13 +170,6 @@ class PosixBackupDriverTestCase(test.TestCase):
|
||||
|
||||
self.driver.delete_object(FAKE_CONTAINER, FAKE_OBJECT_NAME)
|
||||
|
||||
def test_delete_nonexistent_object(self):
|
||||
self.mock_object(os, 'remove', side_effect=OSError)
|
||||
|
||||
self.assertRaises(OSError,
|
||||
self.driver.delete_object, FAKE_CONTAINER,
|
||||
FAKE_OBJECT_NAME)
|
||||
|
||||
@mock.patch.object(posix.timeutils, 'utcnow')
|
||||
def test_generate_object_name_prefix(self, utcnow_mock):
|
||||
timestamp = '20170518102205'
|
||||
|
Loading…
Reference in New Issue
Block a user