From 969f1ea9392589c22266ecd5cba326cbd4630fa3 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 1 Oct 2015 21:10:43 +0000 Subject: [PATCH] Fix slorange on-disk format when including whole object Not that the current implementation is broken, just wasteful. When a client specifies a range for an SLO segment that includes the entire referenced object, we should drop the 'range' key from the manifest that's stored on disk. Previously, we would do this if the uploaded manifest included the object-length for validation, but not if it didn't. Now we will always drop the 'range' key if the entire segment is being used. Change-Id: I69d2fff8c7c59b81e9e4777bdbefcd3c274b59a9 Related-Change: Ia21d51c2cef4e2ee5162161dd2c1d3069009b52c --- swift/common/middleware/slo.py | 2 +- test/unit/common/middleware/test_slo.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/swift/common/middleware/slo.py b/swift/common/middleware/slo.py index ac49ae65ff..4ff2d21cbc 100644 --- a/swift/common/middleware/slo.py +++ b/swift/common/middleware/slo.py @@ -703,7 +703,7 @@ class StaticLargeObject(object): elif len(ranges) > 1: problem_segments.append([quote(obj_name), 'Multiple Ranges']) - elif ranges == [(0, seg_dict['size_bytes'])]: + elif ranges == [(0, head_seg_resp.content_length)]: # Just one range, and it exactly matches the object. # Why'd we do this again? seg_dict['range'] = None diff --git a/test/unit/common/middleware/test_slo.py b/test/unit/common/middleware/test_slo.py index b131240361..f8455a96e6 100644 --- a/test/unit/common/middleware/test_slo.py +++ b/test/unit/common/middleware/test_slo.py @@ -530,7 +530,7 @@ class TestSloPutManifest(SloTestCase): def test_handle_single_ranges(self): good_data = json.dumps( [{'path': '/checktest/a_1', 'etag': None, - 'size_bytes': 1, 'range': '0-0'}, + 'size_bytes': None, 'range': '0-0'}, {'path': '/checktest/b_2', 'etag': None, 'size_bytes': 2, 'range': '-1'}, {'path': '/checktest/b_2', 'etag': None,