diff --git a/neutron/agent/l3/agent.py b/neutron/agent/l3/agent.py index c0ce6774705..7e14d2ab0a7 100644 --- a/neutron/agent/l3/agent.py +++ b/neutron/agent/l3/agent.py @@ -17,6 +17,7 @@ import eventlet import netaddr from neutron_lib import constants as lib_const from oslo_config import cfg +from oslo_context import context as common_context from oslo_log import log as logging import oslo_messaging from oslo_service import loopingcall @@ -191,7 +192,7 @@ class L3NATAgent(ha.AgentMixin, self.driver = common_utils.load_interface_driver(self.conf) - self.context = n_context.get_admin_context_without_session() + self._context = n_context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.L3PLUGIN, host) self.fullsync = True self.sync_routers_chunk_size = SYNC_ROUTERS_MAX_CHUNK_SIZE @@ -610,6 +611,13 @@ class L3NATAgent(ha.AgentMixin, action=queue.DELETE_ROUTER) self._queue.add(update) + @property + def context(self): + # generate a new request-id on each call to make server side tracking + # of RPC calls easier. + self._context.request_id = common_context.generate_request_id() + return self._context + def after_start(self): # Note: the FWaaS' vArmourL3NATAgent is a subclass of L3NATAgent. It # calls this method here. So Removing this after_start() would break diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py index dfbd9dc7630..c162a37165c 100644 --- a/neutron/tests/unit/agent/l3/test_agent.py +++ b/neutron/tests/unit/agent/l3/test_agent.py @@ -184,6 +184,10 @@ class BasicRouterOperationsFramework(base.BaseTestCase): class TestBasicRouterOperations(BasicRouterOperationsFramework): + def test_request_id_changes(self): + a = l3_agent.L3NATAgent(HOSTNAME, self.conf) + self.assertNotEqual(a.context.request_id, a.context.request_id) + def test_init_ha_conf(self): with mock.patch('os.path.dirname', return_value='/etc/ha/'): l3_agent.L3NATAgent(HOSTNAME, self.conf)