diff options
author | Alistair Coles <alistairncoles@gmail.com> | 2021-01-22 13:10:16 +0000 |
---|---|---|
committer | Alistair Coles <alistairncoles@gmail.com> | 2021-01-22 13:10:16 +0000 |
commit | 0a230e5aed3150bcdbf0f9659ee1ab2f74a305eb (patch) | |
tree | c8f98851123cb24e8ff398a7abbbda3db199a587 /swift/proxy/controllers/container.py | |
parent | d429918ed08baf0584e34ed122461ce3e433342b (diff) | |
download | swift-0a230e5aed3150bcdbf0f9659ee1ab2f74a305eb.tar.gz |
Fix logging in proxy container GET path
The proxy tried to map the x-backend-sharding-state header value to
a ShardRange state, but the value is the container *db* state. The
attempted mapping would commonly fail because db state names do not
always correspond to ShardRange state names, in which the case the
fallback was to log the header value i.e. the correct outcome.
Sometimes the attempted mapping would succeed because for example
'sharded' is both a db state name and a ShardRange state name. In that
case the log message would look something like:
"Found 1024 objects in shard (state=(70, 'sharded')), total = 1024"
i.e. the tuple of ShardRange state name and number was logged, which
was inappropriate.
Change-Id: Ic08e6e7df7162a4c1283a3ef6e67c3b21a4ce494
Diffstat (limited to 'swift/proxy/controllers/container.py')
-rw-r--r-- | swift/proxy/controllers/container.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/swift/proxy/controllers/container.py b/swift/proxy/controllers/container.py index 19f631c45..49e4e6f01 100644 --- a/swift/proxy/controllers/container.py +++ b/swift/proxy/controllers/container.py @@ -391,23 +391,19 @@ class ContainerController(Controller): req, shard_range.account, shard_range.container, headers=headers, params=params) - shard_state = 'unknown' - try: - shard_state = shard_resp.headers['x-backend-sharding-state'] - shard_state = ShardRange.resolve_state(shard_state) - except (AttributeError, ValueError, KeyError): - pass + sharding_state = shard_resp.headers.get('x-backend-sharding-state', + 'unknown') if objs is None: # tolerate errors self.app.logger.debug( 'Failed to get objects from shard (state=%s), total = %d', - shard_state, len(objects)) + sharding_state, len(objects)) continue self.app.logger.debug( 'Found %d objects in shard (state=%s), total = %d', - len(objs), shard_state, len(objs) + len(objects)) + len(objs), sharding_state, len(objs) + len(objects)) if not objs: # tolerate empty shard containers |