Prevent routers to be always updated if no shared public network

Current logic assumes that external_fixed_ips should be always defined,
otherwise `req_fip_map` is an empty sequence, which makes _needs_update
to return True.
With that not having external_fixed_ips is a vaild case whenever
deployment does not have shared public network. This usually
the case when public network is not passed to computes and public
network is used only for routers and floating IPs.

Patch changes logic by addind a `is not None` support to only compare
external_fip configration when user explicitly passed something (passing
an empty dict is equal to requesting "empty" configuration).

Co-Authored-by: Artem Goncharov
Change-Id: Id0f69fe4c985c4c38b493577250cad4e589b9d24
This commit is contained in:
Dmitriy Rabotyagov
2023-08-31 15:06:38 +02:00
committed by gtema
parent 8612171af3
commit b25e93dbdd

View File

@@ -366,6 +366,9 @@ class RouterModule(OpenStackModule):
if 'ip_address' in p: if 'ip_address' in p:
cur_fip_map[p['subnet_id']].add(p['ip_address']) cur_fip_map[p['subnet_id']].add(p['ip_address'])
req_fip_map = defaultdict(set) req_fip_map = defaultdict(set)
if external_fixed_ips is not None:
# User passed expected external_fixed_ips configuration.
# Build map of requested ips/subnets.
for p in external_fixed_ips: for p in external_fixed_ips:
if 'ip_address' in p: if 'ip_address' in p:
req_fip_map[p['subnet_id']].add(p['ip_address']) req_fip_map[p['subnet_id']].add(p['ip_address'])
@@ -382,7 +385,7 @@ class RouterModule(OpenStackModule):
# adding ext ip with subnet 'subnet' # adding ext ip with subnet 'subnet'
return True return True
# Check if external ip addresses need to be removed # Check if external ip addresses need to be removed.
for fip in cur_ext_fips: for fip in cur_ext_fips:
subnet = fip['subnet_id'] subnet = fip['subnet_id']
ip = fip['ip_address'] ip = fip['ip_address']
@@ -394,11 +397,6 @@ class RouterModule(OpenStackModule):
# removing ext ip with subnet # removing ext ip with subnet
return True return True
if not external_fixed_ips and len(cur_ext_fips) > 1:
# No external fixed ips requested but
# router has several external fixed ips
return True
# Check if internal interfaces need update # Check if internal interfaces need update
if to_add or to_remove or missing_port_ids: if to_add or to_remove or missing_port_ids:
# need to change interfaces # need to change interfaces
@@ -448,7 +446,8 @@ class RouterModule(OpenStackModule):
return kwargs return kwargs
def _build_router_interface_config(self, filters): def _build_router_interface_config(self, filters):
external_fixed_ips = [] # Undefine external_fixed_ips to have possibility to unset them
external_fixed_ips = None
internal_ports_missing = [] internal_ports_missing = []
internal_ifaces = [] internal_ifaces = []
@@ -459,6 +458,8 @@ class RouterModule(OpenStackModule):
.get('external_fixed_ips') .get('external_fixed_ips')
ext_fixed_ips = ext_fixed_ips or self.params['external_fixed_ips'] ext_fixed_ips = ext_fixed_ips or self.params['external_fixed_ips']
if ext_fixed_ips: if ext_fixed_ips:
# User passed external_fixed_ips configuration. Initialize ips list
external_fixed_ips = []
for iface in ext_fixed_ips: for iface in ext_fixed_ips:
subnet = self.conn.network.find_subnet( subnet = self.conn.network.find_subnet(
iface['subnet'], ignore_missing=False, **filters) iface['subnet'], ignore_missing=False, **filters)