]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Speed up initial L3 full sync time
authorYoni Shafrir <yshafrir@redhat.com>
Mon, 5 Jan 2015 13:27:47 +0000 (15:27 +0200)
committerYoni Shafrir <yshafrir@redhat.com>
Tue, 13 Jan 2015 05:16:08 +0000 (07:16 +0200)
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
neutron/tests/unit/test_l3_agent.py

index 6579566d7b242bb3f6ee92f0fd5d017b82ec244b..e74c1d380c0e0e570a5857594f8dc1066b6711db 100644 (file)
@@ -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'],
index c64a303912385d5d2a9c8ef1b68039e3d1fca6b4..64d22bb3828ee82e52eb111b765186638341439a 100644 (file)
@@ -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 = []