Not set fip to ERROR if it exists on device

The centralized floating IP can exist on the router device
due to some reasons like: uncleaned fip addr, and especially
multiple IP addr adding action: HA router _add_vip() and
Edge router add_ip_address().
This patch catches the IpAddressAlreadyExists error if fip
was already set on the device, and still process next step.

Change-Id: I324f6b96baa0520a0f7ef62a83d81864d7b27999
Closes-Bug: #1811213
(cherry picked from commit 4d45699f15)
This commit is contained in:
LIU Yulong 2019-01-11 09:34:35 +08:00 committed by Miguel Lavalle
parent 119ef92b47
commit 8f93410716
2 changed files with 5 additions and 3 deletions

View File

@ -314,10 +314,11 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
return
interface_name = self.get_snat_external_device_interface_name(
self.get_ex_gw_port())
device = ip_lib.IPDevice(
interface_name, namespace=self.snat_namespace.name)
try:
device.addr.add(fip_cidr)
ip_lib.add_ip_address(fip_cidr, interface_name,
namespace=self.snat_namespace.name)
except ip_lib.IpAddressAlreadyExists:
pass
except RuntimeError:
LOG.warning("Unable to configure IP address for centralized "
"floating IP: %s", fip['id'])

View File

@ -972,6 +972,7 @@ def get_device_mtu(device_name, namespace=None):
NetworkNamespaceNotFound = privileged.NetworkNamespaceNotFound
NetworkInterfaceNotFound = privileged.NetworkInterfaceNotFound
IpAddressAlreadyExists = privileged.IpAddressAlreadyExists
def add_ip_address(cidr, device, namespace=None, scope='global',