From b45fd35e3f4a2aaacc7a22faafd00b7350e4f398 Mon Sep 17 00:00:00 2001 From: Dongcan Ye Date: Mon, 14 Nov 2016 17:35:20 +0800 Subject: [PATCH] Remove floatingip address ignores ha_state We both enables router_distributed and l3_ha in server side, and configures L3 agent node as dvr_snat in compute nodes. HA router removing floatingip address only in master node, and dvr local router only remove FIP rule. This will cause RTNETLINK error if we operates floatingip "associate --> disassociate --> reassociate". This patch removes floatingip address whether router's ha_state is master or backup. Another solution is adding remove_floating_ip in dvr_edge_router. Change-Id: I2fab45cff786c475d69c5f0cf4e9b71e6bbbe653 Closes-Bug: #1641535 --- neutron/agent/l3/ha_router.py | 4 +--- neutron/tests/unit/agent/l3/test_ha_router.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/neutron/agent/l3/ha_router.py b/neutron/agent/l3/ha_router.py index 31659dcc584..004a70a7c26 100644 --- a/neutron/agent/l3/ha_router.py +++ b/neutron/agent/l3/ha_router.py @@ -272,9 +272,7 @@ class HaRouter(router.RouterInfo): def remove_floating_ip(self, device, ip_cidr): self._remove_vip(ip_cidr) - if self.ha_state == 'master' and device.addr.list(to=ip_cidr): - # Delete the floatingip address from external port only after - # the ip address has been configured to the device + if device.addr.list(to=ip_cidr): super(HaRouter, self).remove_floating_ip(device, ip_cidr) def internal_network_updated(self, interface_name, ip_cidrs): diff --git a/neutron/tests/unit/agent/l3/test_ha_router.py b/neutron/tests/unit/agent/l3/test_ha_router.py index dc67327ce18..b2c7bc0f976 100644 --- a/neutron/tests/unit/agent/l3/test_ha_router.py +++ b/neutron/tests/unit/agent/l3/test_ha_router.py @@ -16,6 +16,7 @@ import mock from oslo_utils import uuidutils from neutron.agent.l3 import ha_router +from neutron.agent.l3 import router_info from neutron.tests import base _uuid = uuidutils.generate_uuid @@ -72,3 +73,14 @@ class TestBasicRouterOperations(base.BaseTestCase): subnets[1]['gateway_ip'] = None ri._add_default_gw_virtual_route(ex_gw_port, 'qg-abc') self.assertEqual(0, len(mock_instance.virtual_routes.gateway_routes)) + + @mock.patch.object(router_info.RouterInfo, 'remove_floating_ip') + def test_remove_floating_ip(self, super_remove_floating_ip): + ri = self._create_router(mock.MagicMock()) + mock_instance = mock.Mock() + ri._get_keepalived_instance = mock.Mock(return_value=mock_instance) + device = mock.Mock() + fip_cidr = '15.1.2.3/32' + + ri.remove_floating_ip(device, fip_cidr) + self.assertTrue(super_remove_floating_ip.called)