Fix the missing SLO state on fast-post

When using fast-post and POST (i.e. metadata update) is requested to
a SLO manifest files, current Swift drops the 'X-Static-Large-Object'
header from the existing metadata. It results in breaking the SLO
state because the manifest missing the 'X-Static-Large-Object' metadata
will be maintained as a normal files.

This patch fixes object-server to keep the existing
'X-Static-Large-Object' flag and then keep the SLO state.

Change-Id: Ib1eb569071372c322dd105c52baeeb094003291e
Closes-bug: #1453807
This commit is contained in:
Kota Tsuyuzaki 2015-05-13 00:43:59 -07:00
parent ab163702de
commit 4500ff340f
3 changed files with 13 additions and 4 deletions

View File

@ -444,6 +444,11 @@ class ObjectController(BaseStorageServer):
override = key.lower().replace(override_prefix, 'x-')
update_headers[override] = val
def _preserve_slo_manifest(self, update_metadata, orig_metadata):
if 'X-Static-Large-Object' in orig_metadata:
update_metadata['X-Static-Large-Object'] = \
orig_metadata['X-Static-Large-Object']
@public
@timing_stats()
def POST(self, request):
@ -473,6 +478,7 @@ class ObjectController(BaseStorageServer):
request=request,
headers={'X-Backend-Timestamp': orig_timestamp.internal})
metadata = {'X-Timestamp': req_timestamp.internal}
self._preserve_slo_manifest(metadata, orig_metadata)
metadata.update(val for val in request.headers.items()
if is_user_meta('object', val[0]))
for header_key in self.allowed_headers:

View File

@ -2450,8 +2450,6 @@ class TestSlo(Base):
self.fail("COPY didn't copy the manifest (invalid json on GET)")
def _make_manifest(self):
# To avoid the bug 1453807 on fast-post, make a new manifest
# for post test.
file_item = self.env.container.file("manifest-post")
seg_info = self.env.seg_info
file_item.write(
@ -2473,6 +2471,7 @@ class TestSlo(Base):
updated = self.env.container.file("manifest-post")
updated.info()
updated.header_fields([('user-meta', 'x-object-meta-post')]) # sanity
updated.header_fields([('slo', 'x-static-large-object')])
updated_contents = updated.read(parms={'multipart-manifest': 'get'})
try:
json.loads(updated_contents)
@ -2493,6 +2492,7 @@ class TestSlo(Base):
updated.info()
updated.header_fields(
[('user-meta', 'x-object-meta-post')]) # sanity
updated.header_fields([('slo', 'x-static-large-object')])
updated_contents = updated.read(
parms={'multipart-manifest': 'get'})
try:

View File

@ -253,6 +253,7 @@ class TestObjectController(unittest.TestCase):
'X-Object-Manifest': 'c/bar',
'Content-Encoding': 'gzip',
'Content-Disposition': 'bar',
'X-Static-Large-Object': 'True',
})
req.body = 'VERIFY'
resp = req.get_response(self.object_controller)
@ -263,7 +264,8 @@ class TestObjectController(unittest.TestCase):
"Foo" not in resp.headers and
"Content-Encoding" in resp.headers and
"X-Object-Manifest" in resp.headers and
"Content-Disposition" in resp.headers)
"Content-Disposition" in resp.headers and
"X-Static-Large-Object" in resp.headers)
self.assertEqual(resp.headers['Content-Type'], 'application/x-test')
timestamp = normalize_timestamp(time())
@ -282,7 +284,8 @@ class TestObjectController(unittest.TestCase):
"Content-Encoding" not in resp.headers and
"X-Object-Manifest" not in resp.headers and
"Content-Disposition" not in resp.headers and
"X-Object-Meta-3" in resp.headers)
"X-Object-Meta-3" in resp.headers and
"X-Static-Large-Object" in resp.headers)
self.assertEqual(resp.headers['Content-Type'], 'application/x-test')
# Test for empty metadata