Merge "ratelimit: Log proper container path when returning 498 for listings"

This commit is contained in:
Zuul 2020-12-09 08:48:10 +00:00 committed by Gerrit Code Review
commit 13439edfb2
1 changed files with 7 additions and 4 deletions

View File

@ -282,11 +282,14 @@ class RateLimitMiddleware(object):
if need_to_sleep > 0:
eventlet.sleep(need_to_sleep)
except MaxSleepTimeHitError as e:
if obj_name:
path = '/'.join((account_name, container_name, obj_name))
else:
path = '/'.join((account_name, container_name))
self.logger.error(
_('Returning 498 for %(meth)s to %(acc)s/%(cont)s/%(obj)s '
'. Ratelimit (Max Sleep) %(e)s'),
{'meth': req.method, 'acc': account_name,
'cont': container_name, 'obj': obj_name, 'e': str(e)})
_('Returning 498 for %(meth)s to %(path)s. '
'Ratelimit (Max Sleep) %(e)s'),
{'meth': req.method, 'path': path, 'e': str(e)})
error_resp = Response(status='498 Rate Limited',
body='Slow down', request=req)
return error_resp