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
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'],
import contextlib
import copy
+import eventlet
import mock
import netaddr
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 = []