]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Delete routers that are requested but not reported as active
authorCarl Baldwin <carl.baldwin@hp.com>
Tue, 1 Apr 2014 22:02:17 +0000 (22:02 +0000)
committerMark McClain <mmcclain@yahoo-inc.com>
Tue, 8 Apr 2014 12:22:42 +0000 (08:22 -0400)
There are two cases that I can think of that result in a router being
requested but not reported as active.  One is that admin_state_up has
been set to False.  In this case, the router is never removed and
continues to be operational.

The other case is if a router is changed and then deleted before the
change is processed.  In this case, it is prudent to be sure that the
router is queued for deletion.

Change-Id: I4738f599a18f0d130cc8ad4d4dafc488eec75ffd
Closes-Bug: #1215387
(cherry picked from commit 9da60d0a417dd70c16ae34f5877c564e425e4cf8)

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

index f1e5d9381cb45c04d0cdc59ab8b0efcb9a44cd06..f335da729bba6c1bf4f1dc6526a25b02e997901b 100644 (file)
@@ -771,9 +771,6 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
                 [router['id'] for router in routers])
         cur_router_ids = set()
         for r in routers:
-            if not r['admin_state_up']:
-                continue
-
             # If namespaces are disabled, only process the router associated
             # with the configured agent id.
             if (not self.conf.use_namespaces and
@@ -810,9 +807,13 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
                       len(self.updated_routers))
             if self.updated_routers:
                 router_ids = list(self.updated_routers)
-                self.updated_routers.clear()
                 routers = self.plugin_rpc.get_routers(
                     self.context, router_ids)
+
+                fetched = set([r['id'] for r in routers])
+                self.removed_routers.update(self.updated_routers - fetched)
+                self.updated_routers.clear()
+
                 self._process_routers(routers)
             self._process_router_delete()
             LOG.debug(_("RPC loop successfully completed"))
index 6ccb64778cba4bdc29b824d95ce49b8e35492875..d1dffffb4cb187ea2c3be502387eef6ba5f1fca2 100644 (file)
@@ -895,17 +895,6 @@ class TestBasicRouterOperations(base.BaseTestCase):
             namespace=ri.ns_name,
             prefix=l3_agent.EXTERNAL_DEV_PREFIX)
 
-    def test_routers_with_admin_state_down(self):
-        agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
-        self.plugin_api.get_external_network_id.return_value = None
-
-        routers = [
-            {'id': _uuid(),
-             'admin_state_up': False,
-             'external_gateway_info': {}}]
-        agent._process_routers(routers)
-        self.assertNotIn(routers[0]['id'], agent.router_info)
-
     def test_router_deleted(self):
         agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
         agent.router_deleted(None, FAKE_ID)