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

Resolves: rhbz#2104947

src/pybind/mgr/cephadm/serve.py

index c43abca16e320c1024eea8f3eac5156b84e18d0f..cea88bb18e41f8eb838e80a84f4a7d8f2e9d1df6 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