diff --git a/nova/rpc/impl_carrot.py b/nova/rpc/impl_carrot.py index ee6bac1e5..bfd48773e 100644 --- a/nova/rpc/impl_carrot.py +++ b/nova/rpc/impl_carrot.py @@ -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): diff --git a/nova/rpc/impl_kombu.py b/nova/rpc/impl_kombu.py index f0a8bc61e..1b0d79e06 100644 --- a/nova/rpc/impl_kombu.py +++ b/nova/rpc/impl_kombu.py @@ -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):