]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr/cephadm: add all known good IPs for hosts to haproxy list
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 11 Jul 2023 21:07:25 +0000 (17:07 -0400)
committerAdam King <adking@redhat.com>
Thu, 31 Aug 2023 17:36:15 +0000 (13:36 -0400)
Fixes: https://tracker.ceph.com/issues/61852
It was discovered that when the primary IP address of hosts managed by
cephadm are not all on the same subnet, then there's a chance that
ganesha will reject haproxy protocol connections.

Expand the list to all valid addresses for the hosts under management
such that we will not reject proxy protocol messages from the hosts
under cephadm management. This method was chosen over more sophisticated
possible approaches because we do not want to complicate the workflow
for the people setting up haxproxy+ganesha and do not want to miss any
possible subtle edge cases by trying to come up with the "perfect" list
of addresses.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit aab6a04df274e74d873827724247a1145797441b)

src/pybind/mgr/cephadm/services/nfs.py

index 715a0db729737c79d2c3a3ec42e45fbf22fccc12..f94a00f5bdf944b55e635764594f71e697188a95 100644 (file)
@@ -1,4 +1,5 @@
 import errno
+import ipaddress
 import logging
 import os
 import subprocess
@@ -310,7 +311,21 @@ class NFSService(CephService):
         # good enough to prevent acceping haproxy protocol messages
         # from "rouge" systems that are not under our control. At
         # least until we learn otherwise.
-        return [
-            self.mgr.inventory.get_addr(h)
-            for h in self.mgr.inventory.keys()
-        ]
+        cluster_ips: List[str] = []
+        for host in self.mgr.inventory.keys():
+            default_addr = self.mgr.inventory.get_addr(host)
+            cluster_ips.append(default_addr)
+            nets = self.mgr.cache.networks.get(host)
+            if not nets:
+                continue
+            for subnet, iface in nets.items():
+                ip_subnet = ipaddress.ip_network(subnet)
+                if ipaddress.ip_address(default_addr) in ip_subnet:
+                    continue  # already present
+                if ip_subnet.is_loopback or ip_subnet.is_link_local:
+                    continue  # ignore special subnets
+                addrs: List[str] = sum((addr_list for addr_list in iface.values()), [])
+                if addrs:
+                    # one address per interface/subnet is enough
+                    cluster_ips.append(addrs[0])
+        return cluster_ips