]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Cleanup floatingips also on router delete
authorrajeev <rajeev.grover@hp.com>
Thu, 11 Sep 2014 16:03:00 +0000 (12:03 -0400)
committerrajeev <rajeev.grover@hp.com>
Thu, 11 Sep 2014 19:07:00 +0000 (15:07 -0400)
In router remove path process_router(), processing of floating ips
is getting skipped. This change adds processing of floating ips
if the external gateway for the router was previously set. Since
DVR uses FIP namespaces and agent gateway ports, this change ensures
such ports and namespaces are removed.

Change-Id: Ib1d8fb54adcd8aab411dced695d171376687c980
Partial-bug: #1367588

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

index 6531a6bc628dbdabca68b3390fe3b3442726e3d0..f2ef1ec00684ffe0b4408bbe4cb26d9f616acdf2 100644 (file)
@@ -918,7 +918,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
         # Process SNAT/DNAT rules for floating IPs
         fip_statuses = {}
         try:
-            if ex_gw_port:
+            if ex_gw_port or ri.ex_gw_port:
                 existing_floating_ips = ri.floating_ips
                 self.process_router_floating_ip_nat_rules(ri)
                 ri.iptables_manager.defer_apply_off()
@@ -932,7 +932,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
             for fip in ri.router.get(l3_constants.FLOATINGIP_KEY, []):
                 fip_statuses[fip['id']] = l3_constants.FLOATINGIP_STATUS_ERROR
 
-        if ex_gw_port:
+        if ex_gw_port or ri.ex_gw_port:
             # Identify floating IPs which were disabled
             ri.floating_ips = set(fip_statuses.keys())
             for fip_id in existing_floating_ips - ri.floating_ips:
index 42d0d09ef3fa72bfa148852b7115fee7def850b5..bfe98fdc857a20ae2216c7d6e66fb34edb6ef8b2 100644 (file)
@@ -955,7 +955,17 @@ class TestBasicRouterOperations(base.BaseTestCase):
         del router[l3_constants.INTERFACE_KEY]
         del router['gw_port']
         agent.process_router(ri)
+        ex_gw_port = agent._get_ex_gw_port(ri)
         self.assertEqual(self.send_arp.call_count, 1)
+        agent.process_router_floating_ip_addresses.assert_called_with(
+            ri, ex_gw_port)
+        agent.process_router_floating_ip_addresses.reset_mock()
+        agent.process_router_floating_ip_nat_rules.assert_called_with(ri)
+        agent.process_router_floating_ip_nat_rules.reset_mock()
+
+        # now no ports no gateway, test state tear down
+        ri.ex_gw_port = None
+        agent.process_router(ri)
         self.assertFalse(agent.process_router_floating_ip_addresses.called)
         self.assertFalse(agent.process_router_floating_ip_nat_rules.called)