Merge "Simplify object path when reporting SLO put errors"
This commit is contained in:
commit
c7d521bc6e
@ -255,8 +255,10 @@ class StaticLargeObject(object):
|
|||||||
data_for_storage = []
|
data_for_storage = []
|
||||||
slo_etag = md5()
|
slo_etag = md5()
|
||||||
for index, seg_dict in enumerate(parsed_data):
|
for index, seg_dict in enumerate(parsed_data):
|
||||||
obj_path = '/'.join(
|
obj_name = seg_dict['path']
|
||||||
['', vrs, account, seg_dict['path'].lstrip('/')])
|
if isinstance(obj_name, unicode):
|
||||||
|
obj_name = obj_name.encode('utf-8')
|
||||||
|
obj_path = '/'.join(['', vrs, account, obj_name.lstrip('/')])
|
||||||
try:
|
try:
|
||||||
seg_size = int(seg_dict['size_bytes'])
|
seg_size = int(seg_dict['size_bytes'])
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
@ -268,8 +270,6 @@ class StaticLargeObject(object):
|
|||||||
'%d bytes.' % self.min_segment_size)
|
'%d bytes.' % self.min_segment_size)
|
||||||
|
|
||||||
new_env = req.environ.copy()
|
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['PATH_INFO'] = obj_path
|
||||||
new_env['REQUEST_METHOD'] = 'HEAD'
|
new_env['REQUEST_METHOD'] = 'HEAD'
|
||||||
new_env['swift.source'] = 'SLO'
|
new_env['swift.source'] = 'SLO'
|
||||||
@ -283,11 +283,11 @@ class StaticLargeObject(object):
|
|||||||
if head_seg_resp.is_success:
|
if head_seg_resp.is_success:
|
||||||
total_size += seg_size
|
total_size += seg_size
|
||||||
if seg_size != head_seg_resp.content_length:
|
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:
|
if seg_dict['etag'] == head_seg_resp.etag:
|
||||||
slo_etag.update(seg_dict['etag'])
|
slo_etag.update(seg_dict['etag'])
|
||||||
else:
|
else:
|
||||||
problem_segments.append([quote(obj_path), 'Etag Mismatch'])
|
problem_segments.append([quote(obj_name), 'Etag Mismatch'])
|
||||||
if head_seg_resp.last_modified:
|
if head_seg_resp.last_modified:
|
||||||
last_modified = head_seg_resp.last_modified
|
last_modified = head_seg_resp.last_modified
|
||||||
else:
|
else:
|
||||||
@ -307,7 +307,7 @@ class StaticLargeObject(object):
|
|||||||
data_for_storage.append(seg_data)
|
data_for_storage.append(seg_data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
problem_segments.append([quote(obj_path),
|
problem_segments.append([quote(obj_name),
|
||||||
head_seg_resp.status])
|
head_seg_resp.status])
|
||||||
if problem_segments:
|
if problem_segments:
|
||||||
resp_body = get_response_body(
|
resp_body = get_response_body(
|
||||||
|
@ -374,12 +374,13 @@ class TestStaticLargeObject(unittest.TestCase):
|
|||||||
self.assertEquals(self.app.calls, 4)
|
self.assertEquals(self.app.calls, 4)
|
||||||
data = json.loads(e.body)
|
data = json.loads(e.body)
|
||||||
errors = data['Errors']
|
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[0][1], 'Size Mismatch')
|
||||||
|
self.assertEquals(errors[2][0], '/c/a_2')
|
||||||
self.assertEquals(errors[2][1], '400 Bad Request')
|
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[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')
|
self.assertEquals(errors[-1][1], 'Etag Mismatch')
|
||||||
else:
|
else:
|
||||||
self.assert_(False)
|
self.assert_(False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user