]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: loop over all vips when trying to find ingress' interface 47513/head
authorLuis Domingues <domingues.luis@protonmail.ch>
Thu, 11 Aug 2022 10:01:23 +0000 (11:01 +0100)
committerLuis Domingues <domingues.luis@protonmail.ch>
Thu, 11 Aug 2022 10:01:23 +0000 (11:01 +0100)
Signed-off-by: Luis Domingues <domingues.luis@protonmail.ch>
src/pybind/mgr/cephadm/services/ingress.py

index 0cd888be44edab712a75ea124ed2c1edcbf3aaba..a17fedff1b05d81dac622a23cea664e8bbc760ba 100644 (file)
@@ -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():