Tolerate 404s when DELETEing multipart upload marker

As long as we got a response when we HEADed the thing, that's good
enough.

Closes-Bug: 1638512
Change-Id: I3d7a6ca50cf1a6c9dce08b9eb069eca2d4112922
This commit is contained in:
Tim Burke 2017-08-31 20:47:17 +00:00 committed by Kota Tsuyuzaki
parent 30aa1842a8
commit 7524c3ace8
2 changed files with 21 additions and 1 deletions

View File

@ -612,7 +612,10 @@ class UploadController(Controller):
# clean up the multipart-upload record
obj = '%s/%s' % (req.object_name, upload_id)
req.get_response(self.app, 'DELETE', container, obj)
try:
req.get_response(self.app, 'DELETE', container, obj)
except NoSuchKey:
pass # We know that this existed long enough for us to HEAD
result_elem = Element('CompleteMultipartUploadResult')

View File

@ -621,6 +621,23 @@ class TestSwift3MultiUpload(Swift3TestCase):
self.assertEqual(headers.get('X-Object-Meta-Foo'), 'bar')
self.assertEqual(headers.get('Content-Type'), 'baz/quux')
def test_object_multipart_upload_complete_404_on_marker_delete(self):
segment_bucket = '/v1/AUTH_test/bucket+segments'
self.swift.register('DELETE', segment_bucket + '/object/X',
swob.HTTPNotFound, {}, None)
req = Request.blank('/bucket/object?uploadId=X',
environ={'REQUEST_METHOD': 'POST'},
headers={'Authorization': 'AWS test:tester:hmac',
'Date': self.get_date_header(), },
body=xml)
status, headers, body = self.call_swift3(req)
self.assertEqual(status.split()[0], '200')
fromstring(body, 'CompleteMultipartUploadResult')
_, _, headers = self.swift.calls_with_headers[-2]
self.assertEqual(headers.get('X-Object-Meta-Foo'), 'bar')
self.assertEqual(headers.get('Content-Type'), 'baz/quux')
def test_object_multipart_upload_complete_weird_host_name(self):
# This happens via boto signature v4
req = Request.blank('/bucket/object?uploadId=X',