Simplify object path when reporting SLO put errors

When reporting errors for SLO PUT requests, use the object path from the
manifest without the '/vrs/account' prefix. This is a continuation of
the same changes made for SLO/bulk delete requests in 6768d5b.

Change-Id: I40c90cccc1b7b5303d9f2b084dccb3be4f4448d8
This commit is contained in:
Brian D. Burns 2013-09-29 15:22:05 -04:00
parent 5eea524d3e
commit f9c4eb806f
2 changed files with 11 additions and 10 deletions

View File

@ -255,8 +255,10 @@ class StaticLargeObject(object):
data_for_storage = []
slo_etag = md5()
for index, seg_dict in enumerate(parsed_data):
obj_path = '/'.join(
['', vrs, account, seg_dict['path'].lstrip('/')])
obj_name = seg_dict['path']
if isinstance(obj_name, unicode):
obj_name = obj_name.encode('utf-8')
obj_path = '/'.join(['', vrs, account, obj_name.lstrip('/')])
try:
seg_size = int(seg_dict['size_bytes'])
except (ValueError, TypeError):
@ -268,8 +270,6 @@ class StaticLargeObject(object):
'%d bytes.' % self.min_segment_size)
new_env = req.environ.copy()
if isinstance(obj_path, unicode):
obj_path = obj_path.encode('utf-8')
new_env['PATH_INFO'] = obj_path
new_env['REQUEST_METHOD'] = 'HEAD'
new_env['swift.source'] = 'SLO'
@ -283,11 +283,11 @@ class StaticLargeObject(object):
if head_seg_resp.is_success:
total_size += seg_size
if seg_size != head_seg_resp.content_length:
problem_segments.append([quote(obj_path), 'Size Mismatch'])
problem_segments.append([quote(obj_name), 'Size Mismatch'])
if seg_dict['etag'] == head_seg_resp.etag:
slo_etag.update(seg_dict['etag'])
else:
problem_segments.append([quote(obj_path), 'Etag Mismatch'])
problem_segments.append([quote(obj_name), 'Etag Mismatch'])
if head_seg_resp.last_modified:
last_modified = head_seg_resp.last_modified
else:
@ -307,7 +307,7 @@ class StaticLargeObject(object):
data_for_storage.append(seg_data)
else:
problem_segments.append([quote(obj_path),
problem_segments.append([quote(obj_name),
head_seg_resp.status])
if problem_segments:
resp_body = get_response_body(

View File

@ -374,12 +374,13 @@ class TestStaticLargeObject(unittest.TestCase):
self.assertEquals(self.app.calls, 4)
data = json.loads(e.body)
errors = data['Errors']
self.assertEquals(errors[0][0], '/test_good/A/c/a_1')
self.assertEquals(errors[0][0], '/c/a_1')
self.assertEquals(errors[0][1], 'Size Mismatch')
self.assertEquals(errors[2][0], '/c/a_2')
self.assertEquals(errors[2][1], '400 Bad Request')
self.assertEquals(errors[4][0], '/test_good/A/d/b_2')
self.assertEquals(errors[4][0], '/d/b_2')
self.assertEquals(errors[4][1], 'Etag Mismatch')
self.assertEquals(errors[-1][0], '/test_good/A/d/slob')
self.assertEquals(errors[-1][0], '/d/slob')
self.assertEquals(errors[-1][1], 'Etag Mismatch')
else:
self.assert_(False)