Fixing a bug that was causing the logging to display the context info

for the wrong user.
bug: 915608

Change-Id: I5addd27c3c864333a98e454ecb5bc44836912e8a
This commit is contained in:
Naveed Massjouni
2012-01-13 19:38:51 +00:00
parent 5178b1799d
commit 2c4e543b83
2 changed files with 16 additions and 4 deletions

View File

@@ -42,6 +42,7 @@ import greenlet
from nova import context
from nova import exception
from nova import flags
from nova import local
from nova.rpc import common as rpc_common
from nova.rpc.common import RemoteError, LOG
from nova.testing import fake
@@ -253,6 +254,10 @@ class AdapterConsumer(Consumer):
Example: {'method': 'echo', 'args': {'value': 42}}
"""
# It is important to clear the context here, because at this point
# the previous context is stored in local.store.context
if hasattr(local.store, 'context'):
del local.store.context
LOG.debug(_('received %s') % message_data)
# This will be popped off in _unpack_context
msg_id = message_data.get('_msg_id', None)
@@ -485,8 +490,9 @@ def _unpack_context(msg):
value = msg.pop(key)
context_dict[key[9:]] = value
context_dict['msg_id'] = msg.pop('_msg_id', None)
LOG.debug(_('unpacked context: %s'), context_dict)
return RpcContext.from_dict(context_dict)
ctx = RpcContext.from_dict(context_dict)
LOG.debug(_('unpacked context: %s'), ctx.to_dict())
return ctx
def _pack_context(msg, context):

View File

@@ -33,6 +33,7 @@ import kombu.connection
from nova import context
from nova import exception
from nova import flags
from nova import local
from nova.rpc import common as rpc_common
FLAGS = flags.FLAGS
@@ -695,6 +696,10 @@ class ProxyCallback(object):
Example: {'method': 'echo', 'args': {'value': 42}}
"""
# It is important to clear the context here, because at this point
# the previous context is stored in local.store.context
if hasattr(local.store, 'context'):
del local.store.context
LOG.debug(_('received %s') % message_data)
ctxt = _unpack_context(message_data)
method = message_data.get('method')
@@ -741,8 +746,9 @@ def _unpack_context(msg):
value = msg.pop(key)
context_dict[key[9:]] = value
context_dict['msg_id'] = msg.pop('_msg_id', None)
LOG.debug(_('unpacked context: %s'), context_dict)
return RpcContext.from_dict(context_dict)
ctx = RpcContext.from_dict(context_dict)
LOG.debug(_('unpacked context: %s'), ctx.to_dict())
return ctx
def _pack_context(msg, context):