Merge "proxy: print logs when write new shard range cache into memcache."

This commit is contained in:
Zuul 2023-06-14 12:22:29 +00:00 committed by Gerrit Code Review
commit 2343521f75
4 changed files with 13 additions and 2 deletions

View File

@ -239,8 +239,8 @@ class ContainerController(Controller):
memcache = cache_from_env(req.environ, True)
if memcache and ns_bound_list:
# cache in memcache only if shard ranges as expected
self.logger.debug('Caching %d shards for %s',
len(ns_bound_list.bounds), req.path_qs)
self.logger.info('Caching listing shards for %s (%d shards)',
cache_key, len(ns_bound_list.bounds))
memcache.set(cache_key, ns_bound_list.bounds,
time=self.app.recheck_listing_shard_ranges)
return ns_bound_list

View File

@ -386,6 +386,9 @@ class BaseObjectController(Controller):
shard_ranges)
infocache[cache_key] = cached_namespaces
if memcache:
self.logger.info(
'Caching updating shards for %s (%d shards)',
cache_key, len(cached_namespaces.bounds))
memcache.set(
cache_key, cached_namespaces.bounds,
time=self.app.recheck_updating_shard_ranges)

View File

@ -3210,6 +3210,10 @@ class TestContainerController(TestRingBase):
'shard-listing-v2/a/c', self.ns_bound_list.bounds, time=600),
mock.call.set('container/a/c', mock.ANY, time=60)],
self.memcache.calls)
info_lines = self.logger.get_lines_for_level('info')
self.assertIn(
'Caching listing shards for shard-listing-v2/a/c (3 shards)',
info_lines)
# shards were cached
self.assertEqual('sharded',
self.memcache.calls[2][1][1]['sharding_state'])

View File

@ -4358,6 +4358,10 @@ class TestReplicatedObjectController(
'object.shard_updating.cache.miss.200': 1},
stats)
self.assertEqual([], self.app.logger.log_dict['set_statsd_prefix'])
info_lines = self.logger.get_lines_for_level('info')
self.assertIn(
'Caching updating shards for shard-updating-v2/a/c (3 shards)',
info_lines)
backend_requests = fake_conn.requests
account_request = backend_requests[0]