From cbc268e8395d72c8aa6ea05d90bd22f99df1b8db Mon Sep 17 00:00:00 2001 From: Oleg Bondarev Date: Mon, 12 Oct 2015 18:59:55 +0300 Subject: [PATCH] L3 agent: use run_immediately parameter to sync after start Explicit call to periodic resync after start may lead to double syncing. See bug for details. Closes-Bug: #1505282 Change-Id: Ib5e481d579039b2c3e87d4f12cad1241d02fe060 --- neutron/agent/l3/agent.py | 7 +------ neutron/tests/unit/agent/l3/test_agent.py | 8 -------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/neutron/agent/l3/agent.py b/neutron/agent/l3/agent.py index cbf92ca5830..8191c5a814b 100644 --- a/neutron/agent/l3/agent.py +++ b/neutron/agent/l3/agent.py @@ -524,7 +524,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, # NOTE(kevinbenton): this is set to 1 second because the actual interval # is controlled by a FixedIntervalLoopingCall in neutron/service.py that # is responsible for task execution. - @periodic_task.periodic_task(spacing=1) + @periodic_task.periodic_task(spacing=1, run_immediately=True) def periodic_sync_routers_task(self, context): self.process_services_sync(context) if not self.fullsync: @@ -597,8 +597,6 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, # L3NATAgent. eventlet.spawn_n(self._process_routers_loop) LOG.info(_LI("L3 agent started")) - # When L3 agent is ready, we immediately do a full sync - self.periodic_sync_routers_task(self.context) def create_pd_router_update(self): router_id = None @@ -678,9 +676,6 @@ class L3NATAgentWithStateReport(L3NATAgent): # Do the report state before we do the first full sync. self._report_state() - # When L3 agent is ready, we immediately do a full sync - self.periodic_sync_routers_task(self.context) - self.pd.after_start() def agent_updated(self, context, payload): diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py index 9bf76b63069..4784422fc85 100644 --- a/neutron/tests/unit/agent/l3/test_agent.py +++ b/neutron/tests/unit/agent/l3/test_agent.py @@ -186,14 +186,6 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): agent.context) self.assertTrue(agent.fullsync) - def test_l3_initial_full_sync_done(self): - with mock.patch.object(l3_agent.L3NATAgent, - 'periodic_sync_routers_task') as router_sync: - with mock.patch.object(eventlet, 'spawn_n'): - agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) - agent.after_start() - router_sync.assert_called_once_with(agent.context) - def test_l3_initial_report_state_done(self): with mock.patch.object(l3_agent.L3NATAgentWithStateReport, 'periodic_sync_routers_task'),\