summaryrefslogtreecommitdiff
path: root/swift/proxy/controllers/container.py
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2022-04-26 16:12:49 -0700
committerTim Burke <tim.burke@gmail.com>2022-04-28 13:20:44 -0700
commit9bed525bfbe3ec05cb45c9835333fe45f8e04b40 (patch)
treece1cc9ff8ff87829d73db3984898b99e7ae65711 /swift/proxy/controllers/container.py
parentb621a6f932edcda1cdba02534e382b962e759f9e (diff)
downloadswift-9bed525bfbe3ec05cb45c9835333fe45f8e04b40.tar.gz
memcached: Give callers the option to accept errors
Auth middlewares in particular may want to *know* when there's a communication breakdown as opposed to a cache miss. Update our shard-range cache stats to acknowlegde the distinction. Drive-by: Log an error if all memcached servers are error-limited. Change-Id: Ic8d0915235d11124d06ec940c5be9a2edbe85c83
Diffstat (limited to 'swift/proxy/controllers/container.py')
-rw-r--r--swift/proxy/controllers/container.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/swift/proxy/controllers/container.py b/swift/proxy/controllers/container.py
index 4ac00d010..a21a55d22 100644
--- a/swift/proxy/controllers/container.py
+++ b/swift/proxy/controllers/container.py
@@ -20,6 +20,7 @@ import random
import six
from six.moves.urllib.parse import unquote
+from swift.common.memcached import MemcacheConnectionError
from swift.common.utils import public, private, csv_append, Timestamp, \
config_true_value, ShardRange, cache_from_env, filter_shard_ranges
from swift.common.constraints import check_metadata, CONTAINER_LISTING_LIMIT
@@ -152,9 +153,14 @@ class ContainerController(Controller):
if skip_chance and random.random() < skip_chance:
self.logger.increment('shard_listing.cache.skip')
else:
- cached_ranges = memcache.get(cache_key)
- self.logger.increment('shard_listing.cache.%s' % (
- 'hit' if cached_ranges else 'miss'))
+ try:
+ cached_ranges = memcache.get(
+ cache_key, raise_on_error=True)
+ cache_state = 'hit' if cached_ranges else 'miss'
+ except MemcacheConnectionError:
+ cache_state = 'error'
+ self.logger.increment(
+ 'shard_listing.cache.%s' % cache_state)
if cached_ranges is not None:
infocache[cache_key] = tuple(cached_ranges)