Provide correct fip cidr when deleting port forwarding

The second parameter of fip_id_cidrs requires a cidr, but now is address. this
causes function `_sync_and_remove_fip` fail to remove vip as expected.

if current is ha router, in function _sync_and_remove_fip will call
`ri._remove_vip(fip_id_cidr[1])`. the final parameter is passed to
KeepalivedInstance.remove_vip_by_ip_address and compare with attribute vips.
the values of vips are of type CIDR.

if not ha, the following process processing use netaddr.IPNetwork and can be
performed as expected.

Closes-bug: #1873708

Change-Id: I2ae2ade29700a56dc340256389bf8b0efd697ba4
This commit is contained in:
zhouhenglc 2020-04-20 08:34:25 +08:00
parent af1af5d3e7
commit 3a6a8c334a
2 changed files with 4 additions and 3 deletions

View File

@ -344,8 +344,8 @@ class PortForwardingAgentExtension(l3_extension.L3AgentExtension):
iptables_manager.apply()
fip_id_cidrs = set([(pf.floatingip_id,
str(pf.floating_ip_address)) for pf in
port_forwardings])
str(netaddr.IPNetwork(pf.floating_ip_address)))
for pf in port_forwardings])
self._sync_and_remove_fip(context, fip_id_cidrs, device, ri)
self._store_local(port_forwardings, events.DELETED)

View File

@ -14,6 +14,7 @@
# under the License.
import mock
import netaddr
from neutron_lib import constants as lib_const
from neutron_lib import context
from oslo_utils import uuidutils
@ -274,7 +275,7 @@ class FipPortForwardingExtensionTestCase(PortForwardingExtensionBaseTestCase):
self.portforwarding1.external_port,
protocol=self.portforwarding1.protocol)
mock_device.delete_addr_and_conntrack_state.assert_called_once_with(
str(self.portforwarding1.floating_ip_address))
str(netaddr.IPNetwork(self.portforwarding1.floating_ip_address)))
fip_status = {
self.portforwarding1.floatingip_id:
lib_const.FLOATINGIP_STATUS_DOWN}