]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: Fix how we check if a host belongs to public network 47946/head
authorRedouane Kachach <rkachach@redhat.com>
Wed, 31 Aug 2022 11:49:37 +0000 (13:49 +0200)
committerAdam King <adking@redhat.com>
Sat, 3 Sep 2022 17:11:41 +0000 (13:11 -0400)
Fixes: https://tracker.ceph.com/issues/57060
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
(cherry picked from commit 1c8833feaf42fd518e19c9a347c6c5781943862a)

src/pybind/mgr/cephadm/serve.py

index 2f26ca70900f757431e237f913c2f63bcf7281b5..2039bff10985b90379654adec277d737da84a244 100644 (file)
@@ -1,3 +1,4 @@
+import ipaddress
 import hashlib
 import json
 import logging
@@ -608,14 +609,19 @@ class CephadmServe:
 
         def matches_network(host):
             # type: (str) -> bool
-            # make sure we have 1 or more IPs for any of those networks on that
-            # host
-            for network in public_networks:
-                if len(self.mgr.cache.networks[host].get(network, [])) > 0:
-                    return True
+            # make sure the host has at least one network that belongs to some configured public network(s)
+            for pn in public_networks:
+                public_network = ipaddress.ip_network(pn)
+                for hn in self.mgr.cache.networks[host]:
+                    host_network = ipaddress.ip_network(hn)
+                    if host_network.overlaps(public_network):
+                        return True
+
+            host_networks = ','.join(self.mgr.cache.networks[host])
+            pub_networks = ','.join(public_networks)
             self.log.info(
-                f"Filtered out host {host}: does not belong to mon public_network"
-                f" ({','.join(public_networks)})"
+                f"Filtered out host {host}: does not belong to mon public_network(s): "
+                f" {pub_networks}, host network(s): {host_networks}"
             )
             return False