Merge "proxy: Remove unused arg from set/clear_info_cache"

This commit is contained in:
Zuul 2023-06-13 23:35:42 +00:00 committed by Gerrit Code Review
commit 406bbb6abd
4 changed files with 18 additions and 19 deletions

View File

@ -96,7 +96,7 @@ class AccountController(Controller):
# up-to-date information for the account.
resp.headers['X-Backend-Recheck-Account-Existence'] = str(
self.app.recheck_account_existence)
set_info_cache(self.app, req.environ, self.account_name, None, resp)
set_info_cache(req.environ, self.account_name, None, resp)
if req.environ.get('swift_owner'):
self.add_acls_from_sys_metadata(resp)
@ -124,7 +124,7 @@ class AccountController(Controller):
account_partition, accounts = \
self.app.account_ring.get_nodes(self.account_name)
headers = self.generate_request_headers(req, transfer=True)
clear_info_cache(self.app, req.environ, self.account_name)
clear_info_cache(req.environ, self.account_name)
resp = self.make_requests(
req, self.app.account_ring, account_partition, 'PUT',
req.swift_entity_path, [headers] * len(accounts))
@ -146,7 +146,7 @@ class AccountController(Controller):
account_partition, accounts = \
self.app.account_ring.get_nodes(self.account_name)
headers = self.generate_request_headers(req, transfer=True)
clear_info_cache(self.app, req.environ, self.account_name)
clear_info_cache(req.environ, self.account_name)
resp = self.make_requests(
req, self.app.account_ring, account_partition, 'POST',
req.swift_entity_path, [headers] * len(accounts))
@ -173,7 +173,7 @@ class AccountController(Controller):
account_partition, accounts = \
self.app.account_ring.get_nodes(self.account_name)
headers = self.generate_request_headers(req)
clear_info_cache(self.app, req.environ, self.account_name)
clear_info_cache(req.environ, self.account_name)
resp = self.make_requests(
req, self.app.account_ring, account_partition, 'DELETE',
req.swift_entity_path, [headers] * len(accounts))

View File

@ -476,7 +476,7 @@ def get_container_info(env, app, swift_source=None):
# See similar comment in get_account_info() for justification.
info = _get_info_from_infocache(env, account, container)
if info is None:
info = set_info_cache(app, env, account, container, resp)
info = set_info_cache(env, account, container, resp)
if info:
info = deepcopy(info) # avoid mutating what's in swift.infocache
@ -565,7 +565,7 @@ def get_account_info(env, app, swift_source=None):
# memcache would defeat the purpose.
info = _get_info_from_infocache(env, account)
if info is None:
info = set_info_cache(app, env, account, None, resp)
info = set_info_cache(env, account, None, resp)
if info:
info = info.copy() # avoid mutating what's in swift.infocache
@ -632,11 +632,11 @@ def get_cache_key(account, container=None, obj=None, shard=None):
return cache_key
def set_info_cache(app, env, account, container, resp):
def set_info_cache(env, account, container, resp):
"""
Cache info in both memcache and env.
:param app: the application object
:param env: the WSGI request environment
:param account: the unquoted account name
:param container: the unquoted container name or None
:param resp: the response received or None if info cache should be cleared
@ -648,7 +648,7 @@ def set_info_cache(app, env, account, container, resp):
infocache = env.setdefault('swift.infocache', {})
memcache = cache_from_env(env, True)
if resp is None:
clear_info_cache(app, env, account, container)
clear_info_cache(env, account, container)
return
if container:
@ -705,12 +705,11 @@ def set_object_info_cache(app, env, account, container, obj, resp):
return info
def clear_info_cache(app, env, account, container=None, shard=None):
def clear_info_cache(env, account, container=None, shard=None):
"""
Clear the cached info in both memcache and env
:param app: the application object
:param env: the WSGI environment
:param env: the WSGI request environment
:param account: the account name
:param container: the container name if clearing info for containers, or
None
@ -2157,7 +2156,7 @@ class Controller(object):
path, [headers] * len(nodes))
if is_success(resp.status_int):
self.logger.info('autocreate account %r', path)
clear_info_cache(self.app, req.environ, account)
clear_info_cache(req.environ, account)
return True
else:
self.logger.warning('Could not autocreate account %r', path)

View File

@ -92,9 +92,9 @@ class ContainerController(Controller):
return None
def _clear_container_info_cache(self, req):
clear_info_cache(self.app, req.environ,
clear_info_cache(req.environ,
self.account_name, self.container_name)
clear_info_cache(self.app, req.environ,
clear_info_cache(req.environ,
self.account_name, self.container_name, 'listing')
# TODO: should we also purge updating shards from cache?
@ -430,7 +430,7 @@ class ContainerController(Controller):
# node and got up-to-date information for the container.
resp.headers['X-Backend-Recheck-Container-Existence'] = str(
self.app.recheck_container_existence)
set_info_cache(self.app, req.environ, self.account_name,
set_info_cache(req.environ, self.account_name,
self.container_name, resp)
if 'swift.authorize' in req.environ:
req.acl = resp.headers.get('x-container-read')

View File

@ -571,12 +571,12 @@ class TestFuncs(BaseTest):
check_in_cache(req, acct_cache_key)
check_in_cache(req, cont_cache_key)
clear_info_cache('app-is-unused', req.environ, 'account', 'cont')
clear_info_cache(req.environ, 'account', 'cont')
check_in_cache(req, acct_cache_key)
check_not_in_cache(req, cont_cache_key)
# Can also use set_info_cache interface
set_info_cache('app-is-unused', req.environ, 'account', None, None)
set_info_cache(req.environ, 'account', None, None)
check_not_in_cache(req, acct_cache_key)
check_not_in_cache(req, cont_cache_key)
@ -586,7 +586,7 @@ class TestFuncs(BaseTest):
req.environ['swift.infocache'][shard_cache_key] = shard_data
req.environ['swift.cache'].set(shard_cache_key, shard_data, time=600)
check_in_cache(req, shard_cache_key)
clear_info_cache('app-is-unused', req.environ, 'account', 'cont',
clear_info_cache(req.environ, 'account', 'cont',
shard='listing')
check_not_in_cache(req, shard_cache_key)