summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian D. Burns <iosctr@gmail.com>2013-09-29 15:22:05 -0400
committerBrian D. Burns <iosctr@gmail.com>2013-09-29 15:22:05 -0400
commitf9c4eb806f14ce095554d70261504781dbb7aa3e (patch)
treed7bf5d92a4852feb715aff3cc2196eedf9b8af2f
parent5eea524d3ea6d29c2b6f34927c0130090e7ed44d (diff)
downloadswift-f9c4eb806f14ce095554d70261504781dbb7aa3e.tar.gz
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
-rw-r--r--swift/common/middleware/slo.py14
-rw-r--r--test/unit/common/middleware/test_slo.py7
2 files changed, 11 insertions, 10 deletions
diff --git a/swift/common/middleware/slo.py b/swift/common/middleware/slo.py
index df4f21d71..1c98acca3 100644
--- a/swift/common/middleware/slo.py
+++ b/swift/common/middleware/slo.py
@@ -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(
diff --git a/test/unit/common/middleware/test_slo.py b/test/unit/common/middleware/test_slo.py
index 7586ff02e..853375606 100644
--- a/test/unit/common/middleware/test_slo.py
+++ b/test/unit/common/middleware/test_slo.py
@@ -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)