From fff86b689e2ff0d4f6815ba1dd22ea7805202ab5 Mon Sep 17 00:00:00 2001 From: Yoni Shafrir Date: Mon, 5 Jan 2015 15:27:47 +0200 Subject: [PATCH] Speed up initial L3 full sync time When a L3 agent starts up the initial full sync occurs on the first periodic task interval. This means that from the point the agent is ready to process updates it can take ~1 minute until traffic can start flowing through the L3 agent's routers. When using a highly available solution (not VRRP) the startup delay adds around a full minute to the minimum downtime. This patch simply does a manual (i.e. not periodic) full sync once the L3 agent is ready (in 'after_start' method). The change results in a much faster sync on a new agent. With the patch it takes several seconds until routers are created on the new/restarted L3 agent. Closes-Bug: #1407410 Change-Id: I2447a4cdfff5e915f0b5da88e16c9b6944ea9563 --- neutron/agent/l3/agent.py | 2 ++ neutron/tests/unit/test_l3_agent.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/neutron/agent/l3/agent.py b/neutron/agent/l3/agent.py index 6579566d7..e74c1d380 100644 --- a/neutron/agent/l3/agent.py +++ b/neutron/agent/l3/agent.py @@ -1210,6 +1210,8 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, def after_start(self): 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 _update_routing_table(self, ri, operation, route): cmd = ['ip', 'route', operation, 'to', route['destination'], diff --git a/neutron/tests/unit/test_l3_agent.py b/neutron/tests/unit/test_l3_agent.py index c64a30391..64d22bb38 100644 --- a/neutron/tests/unit/test_l3_agent.py +++ b/neutron/tests/unit/test_l3_agent.py @@ -15,6 +15,7 @@ import contextlib import copy +import eventlet import mock import netaddr @@ -283,6 +284,14 @@ class TestBasicRouterOperations(base.BaseTestCase): self.assertTrue(agent.fullsync) self.assertFalse(f.called) + 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_periodic_sync_routers_task_call_clean_stale_namespaces(self): agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) self.plugin_api.get_routers.return_value = [] -- 2.45.2