swift backup driver: Ignore 404 during object deletion
Swift may return 404 to object deletion even though the object is (or will be) actually removed, and 404 can be treated as success. Closes-Bug: #2061988 Change-Id: I3a60cb5951b072d2c184fe1bc6dbc765cd46642a
This commit is contained in:
parent
b0f0b9015b
commit
a34ded4873
@ -419,6 +419,9 @@ class SwiftBackupDriver(chunkeddriver.ChunkedBackupDriver):
|
||||
headers=self._headers())
|
||||
except socket.error as err:
|
||||
raise exception.SwiftConnectionFailed(reason=err)
|
||||
except swift_exc.ClientException as err:
|
||||
if err.http_status != 404:
|
||||
raise
|
||||
|
||||
def _generate_object_name_prefix(self, backup):
|
||||
"""Generates a Swift backup object name prefix."""
|
||||
|
@ -888,6 +888,17 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.delete_backup(backup)
|
||||
|
||||
def test_delete_not_found(self):
|
||||
volume_id = '9ab256c8-3175-4ad8-baa1-0000007f9d31'
|
||||
container_name = 'not_found_on_delete'
|
||||
object_prefix = 'test_prefix'
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
service_metadata=object_prefix)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.delete_backup(backup)
|
||||
|
||||
def test_delete_wraps_socket_error(self):
|
||||
volume_id = 'f74cb6fa-2900-40df-87ac-0000000f72ea'
|
||||
container_name = 'socket_error_on_delete'
|
||||
|
@ -20,6 +20,7 @@ import socket
|
||||
import zlib
|
||||
|
||||
from swiftclient import client as swift
|
||||
from swiftclient import exceptions as swift_exc
|
||||
|
||||
|
||||
class FakeSwiftClient(object):
|
||||
@ -105,4 +106,7 @@ class FakeSwiftConnection(object):
|
||||
def delete_object(self, container, name, headers=None):
|
||||
if container == 'socket_error_on_delete':
|
||||
raise socket.error(111, 'ECONNREFUSED')
|
||||
if container == 'not_found_on_delete':
|
||||
raise swift_exc.ClientException(
|
||||
msg='404 Not Found', http_status=404, http_reason='Not Found')
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user