From 1b9a6a0f58a9a7550e8b93573b3191816da5f900 Mon Sep 17 00:00:00 2001 From: Luis Domingues Date: Thu, 11 Aug 2022 11:01:23 +0100 Subject: [PATCH] mgr/cephadm: loop over all vips when trying to find ingress' interface Signed-off-by: Luis Domingues --- src/pybind/mgr/cephadm/services/ingress.py | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/pybind/mgr/cephadm/services/ingress.py b/src/pybind/mgr/cephadm/services/ingress.py index 0cd888be44eda..a17fedff1b05d 100644 --- a/src/pybind/mgr/cephadm/services/ingress.py +++ b/src/pybind/mgr/cephadm/services/ingress.py @@ -197,18 +197,23 @@ class IngressService(CephService): hosts = sorted(list(set([host] + [str(d.hostname) for d in daemons]))) # interface + bare_ips = [] if spec.virtual_ip: - bare_ip = str(spec.virtual_ip).split('/')[0] + bare_ips.append(str(spec.virtual_ip).split('/')[0]) elif spec.virtual_ips_list: - bare_ip = str(spec.virtual_ips_list[0]).split('/')[0] + bare_ips = [str(vip).split('/')[0] for vip in spec.virtual_ips_list] interface = None - for subnet, ifaces in self.mgr.cache.networks.get(host, {}).items(): - if ifaces and ipaddress.ip_address(bare_ip) in ipaddress.ip_network(subnet): - interface = list(ifaces.keys())[0] - logger.info( - f'{bare_ip} is in {subnet} on {host} interface {interface}' - ) - break + for bare_ip in bare_ips: + for subnet, ifaces in self.mgr.cache.networks.get(host, {}).items(): + if ifaces and ipaddress.ip_address(bare_ip) in ipaddress.ip_network(subnet): + interface = list(ifaces.keys())[0] + logger.info( + f'{bare_ip} is in {subnet} on {host} interface {interface}' + ) + break + else: # nobreak + continue + break # try to find interface by matching spec.virtual_interface_networks if not interface and spec.virtual_interface_networks: for subnet, ifaces in self.mgr.cache.networks.get(host, {}).items(): -- 2.39.5