From: Luis Domingues Date: Thu, 11 Aug 2022 10:01:23 +0000 (+0100) Subject: mgr/cephadm: loop over all vips when trying to find ingress' interface X-Git-Tag: v18.0.0~262^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1b9a6a0f58a9a7550e8b93573b3191816da5f900;p=ceph.git mgr/cephadm: loop over all vips when trying to find ingress' interface Signed-off-by: Luis Domingues --- 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():