Merge "Split the FIP Namespace delete in L3 agent for DVR"
This commit is contained in:
commit
6c1c1bbcec
@ -136,26 +136,10 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
|
||||
self.fip_ns.local_subnets.release(self.router_id)
|
||||
self.rtr_fip_subnet = None
|
||||
ns_ip.del_veth(fip_2_rtr_name)
|
||||
is_last = self.fip_ns.unsubscribe(self.router_id)
|
||||
if is_last:
|
||||
# TODO(Carl) I can't help but think that another router could
|
||||
# come in and want to start using this namespace while this is
|
||||
# destroying it. The two could end up conflicting on
|
||||
# creating/destroying interfaces and such. I think I'd like a
|
||||
# semaphore to sync creation/deletion of this namespace.
|
||||
|
||||
# NOTE (Swami): Since we are deleting the namespace here we
|
||||
# should be able to delete the floatingip agent gateway port
|
||||
# for the provided external net since we don't need it anymore.
|
||||
if self.fip_ns.agent_gateway_port:
|
||||
LOG.debug('Removed last floatingip, so requesting the '
|
||||
'server to delete Floatingip Agent Gateway port:'
|
||||
'%s', self.fip_ns.agent_gateway_port)
|
||||
self.agent.plugin_rpc.delete_agent_gateway_port(
|
||||
self.agent.context,
|
||||
self.fip_ns.agent_gateway_port['network_id'])
|
||||
self.fip_ns.delete()
|
||||
self.fip_ns = None
|
||||
self.fip_ns.unsubscribe(self.router_id)
|
||||
# NOTE (Swami): The fg interface and the namespace will be deleted
|
||||
# when the external gateway port is removed. This will be
|
||||
# initiated from the server through an RPC call.
|
||||
|
||||
def add_floating_ip(self, fip, interface_name, device):
|
||||
if not self._add_fip_addr_to_device(fip, device):
|
||||
|
@ -1154,7 +1154,6 @@ class TestDvrRouter(L3AgentTestFramework):
|
||||
router, ip_versions, snat_ns_name)
|
||||
|
||||
self._delete_router(self.agent, router.router_id)
|
||||
self._assert_interfaces_deleted_from_ovs()
|
||||
self._assert_router_does_not_exist(router)
|
||||
self._assert_snat_namespace_does_not_exist(router)
|
||||
|
||||
@ -1362,7 +1361,7 @@ class TestDvrRouter(L3AgentTestFramework):
|
||||
router1.router[l3_constants.FLOATINGIP_KEY] = []
|
||||
self.manage_router(restarted_agent, router1.router)
|
||||
self._assert_dvr_snat_gateway(router1)
|
||||
self.assertFalse(self._namespace_exists(fip_ns))
|
||||
self.assertTrue(self._namespace_exists(fip_ns))
|
||||
|
||||
def test_dvr_router_add_fips_on_restarted_agent(self):
|
||||
self.agent.conf.agent_mode = 'dvr'
|
||||
@ -1521,30 +1520,6 @@ class TestDvrRouter(L3AgentTestFramework):
|
||||
self.assertFalse(sg_device)
|
||||
self.assertTrue(qg_device)
|
||||
|
||||
def test_dvr_router_calls_delete_agent_gateway_if_last_fip(self):
|
||||
"""Test to validate delete fip if it is last fip managed by agent."""
|
||||
self.agent.conf.agent_mode = 'dvr_snat'
|
||||
router_info = self.generate_dvr_router_info(enable_snat=True)
|
||||
router1 = self.manage_router(self.agent, router_info)
|
||||
floating_agent_gw_port = (
|
||||
router1.router[l3_constants.FLOATINGIP_AGENT_INTF_KEY])
|
||||
self.assertTrue(floating_agent_gw_port)
|
||||
fip_ns = router1.fip_ns.get_name()
|
||||
router1.fip_ns.agent_gw_port = floating_agent_gw_port
|
||||
self.assertTrue(self._namespace_exists(router1.ns_name))
|
||||
self.assertTrue(self._namespace_exists(fip_ns))
|
||||
self._assert_dvr_floating_ips(router1)
|
||||
self._assert_dvr_snat_gateway(router1)
|
||||
router1.router[l3_constants.FLOATINGIP_KEY] = []
|
||||
rpc_mock = mock.patch.object(
|
||||
self.agent.plugin_rpc, 'delete_agent_gateway_port').start()
|
||||
self.agent._process_updated_router(router1.router)
|
||||
self.assertTrue(rpc_mock.called)
|
||||
rpc_mock.assert_called_once_with(
|
||||
self.agent.context,
|
||||
floating_agent_gw_port[0]['network_id'])
|
||||
self.assertFalse(self._namespace_exists(fip_ns))
|
||||
|
||||
def _mocked_dvr_ha_router(self, agent):
|
||||
r_info = self.generate_dvr_router_info(enable_ha=True,
|
||||
enable_snat=True,
|
||||
|
@ -242,10 +242,7 @@ class TestDvrRouterOperations(base.BaseTestCase):
|
||||
ri.rtr_fip_subnet = lla.LinkLocalAddressPair('15.1.2.3/32')
|
||||
_, fip_to_rtr = ri.rtr_fip_subnet.get_pair()
|
||||
fip_ns = ri.fip_ns
|
||||
with mock.patch.object(self.plugin_api,
|
||||
'delete_agent_gateway_port') as del_fip_gw:
|
||||
ri.floating_ip_removed_dist(fip_cidr)
|
||||
self.assertTrue(del_fip_gw.called)
|
||||
self.assertTrue(fip_ns.destroyed)
|
||||
mIPWrapper().del_veth.assert_called_once_with(
|
||||
fip_ns.get_int_device_name(router['id']))
|
||||
|
Loading…
Reference in New Issue
Block a user