]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Clean out namespaces even if we don't delete namespaces
authorCarl Baldwin <carl.baldwin@hp.com>
Tue, 1 Apr 2014 22:16:59 +0000 (22:16 +0000)
committerCarl Baldwin <carl.baldwin@hp.com>
Fri, 4 Apr 2014 16:04:57 +0000 (16:04 +0000)
Even when we don't enable namespace deletion, we still want to run the
code that cleans out the namespaces so that the devices get unplugged,
etc.  Otherwise, routers deleted while the agent is down will continue
to operate as if they were never deleted.

The trade-off to consider here is that if there are many stale
namespaces this will slow down the restart of the L3 agent.  The best
option is to get namespace deletion working correctly.  However, where
that has not been worked out yet, this patch provides the cleaning
service for deleted routers.

Change-Id: Ic7b4608a23c4d9530f521d5faff3f8526200b92e
Closes-Bug: #1301042
Related-Bug: #1052535

neutron/agent/l3_agent.py
neutron/tests/unit/test_l3_agent.py

index 5b7d709d6bfa6be310e65bc58a19dd53fcb27f30..52fb3cfeb9e5ce7012d2cbe63d9d94fd071bf49f 100644 (file)
@@ -220,8 +220,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
         self.removed_routers = set()
         self.sync_progress = False
 
-        self._delete_stale_namespaces = (self.conf.use_namespaces and
-                                         self.conf.router_delete_namespaces)
+        self._clean_stale_namespaces = self.conf.use_namespaces
 
         self.rpc_loop = loopingcall.FixedIntervalLoopingCall(
             self._rpc_loop)
@@ -249,7 +248,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
     def _cleanup_namespaces(self, routers):
         """Destroy stale router namespaces on host when L3 agent restarts
 
-        This routine is called when self._delete_stale_namespaces is True.
+        This routine is called when self._clean_stale_namespaces is True.
 
         The argument routers is the list of routers that are recorded in
         the database as being hosted on this node.
@@ -285,7 +284,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
             except RuntimeError:
                 LOG.exception(_('Failed to destroy stale router namespace '
                                 '%s'), ns)
-        self._delete_stale_namespaces = False
+        self._clean_stale_namespaces = False
 
     def _destroy_router_namespace(self, namespace):
         ns_ip = ip_lib.IPWrapper(self.root_helper, namespace=namespace)
@@ -864,7 +863,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
 
         # Resync is not necessary for the cleanup of stale
         # namespaces.
-        if self._delete_stale_namespaces:
+        if self._clean_stale_namespaces:
             self._cleanup_namespaces(routers)
 
     def after_start(self):
index d390ac29bd6e83161cd04a2f1cbbccedf1767384..14d9f32dc16ea6bc9cc6d65cf8aa3f0904859d25 100644 (file)
@@ -984,7 +984,7 @@ class TestBasicRouterOperations(base.BaseTestCase):
         self.conf.set_override('router_id', '1234')
         agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
         self.assertEqual(['1234'], agent._router_ids())
-        self.assertFalse(agent._delete_stale_namespaces)
+        self.assertFalse(agent._clean_stale_namespaces)
 
     def test_process_routers_with_no_ext_net_in_conf(self):
         agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
@@ -1130,7 +1130,7 @@ class TestBasicRouterOperations(base.BaseTestCase):
 
         agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
 
-        self.assertTrue(agent._delete_stale_namespaces)
+        self.assertTrue(agent._clean_stale_namespaces)
 
         pm = self.external_process.return_value
         pm.reset_mock()
@@ -1144,7 +1144,7 @@ class TestBasicRouterOperations(base.BaseTestCase):
         expected_args = [mock.call(ns) for ns in stale_namespace_list]
         agent._destroy_router_namespace.assert_has_calls(expected_args,
                                                          any_order=True)
-        self.assertFalse(agent._delete_stale_namespaces)
+        self.assertFalse(agent._clean_stale_namespaces)
 
     def test_cleanup_namespace(self):
         self.conf.set_override('router_id', None)