Pop off user/tenant kwargs in RequestContext init
The RequestContextSerializer uses the to_dict and from_dict methods and to_dict is storing user/tenant fields which end up unaccounted for in the RequestContext constructor kwargs which means we log a warning every time we hydrate the context - which is a lot (~89K times in 2 days of CI runs). This change simply pops the user/tenant from kwargs before logging the warning and uses them in case user_id or project_id are None for some reason, which is similar to what Nova's RequestContext does. Change-Id: I57b4854d60d5758a67df5edcdcddeeb0a4ad886d Closes-Bug: #1528348
This commit is contained in:
parent
efdf04ead1
commit
e86ebb1e39
@ -54,12 +54,14 @@ class RequestContext(object):
|
||||
:param kwargs: Extra arguments that might be present, but we ignore
|
||||
because they possibly came in from older rpc messages.
|
||||
"""
|
||||
user = kwargs.pop('user', None)
|
||||
tenant = kwargs.pop('tenant', None)
|
||||
if kwargs:
|
||||
LOG.warn(_LW('Arguments dropped when creating context: %s'),
|
||||
str(kwargs))
|
||||
|
||||
self.user_id = user_id
|
||||
self.project_id = project_id
|
||||
self.user_id = user_id or user
|
||||
self.project_id = project_id or tenant
|
||||
self.roles = roles or []
|
||||
self.is_admin = is_admin
|
||||
if self.is_admin is None:
|
||||
|
@ -74,7 +74,12 @@ class ContextTestCase(test.TestCase):
|
||||
c = context.RequestContext('user',
|
||||
'project',
|
||||
extra_arg1='meow',
|
||||
extra_arg2='wuff')
|
||||
extra_arg2='wuff',
|
||||
user='user',
|
||||
tenant='project')
|
||||
self.assertTrue(c)
|
||||
self.assertIn("'extra_arg1': 'meow'", info['log_msg'])
|
||||
self.assertIn("'extra_arg2': 'wuff'", info['log_msg'])
|
||||
# user and tenant kwargs get popped off before we log anything
|
||||
self.assertNotIn("'user': 'user'", info['log_msg'])
|
||||
self.assertNotIn("'tenant': 'project'", info['log_msg'])
|
||||
|
Loading…
Reference in New Issue
Block a user