]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: allow binding to loopback for rgw daemons
authorRedouane Kachach <rkachach@redhat.com>
Fri, 26 Aug 2022 12:00:05 +0000 (14:00 +0200)
committerAdam King <adking@redhat.com>
Thu, 8 Sep 2022 17:23:03 +0000 (13:23 -0400)
Fixes: https://tracker.ceph.com/issues/57304
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
(cherry picked from commit 1a722f35c1f40353dbdf06fdb63364822ebaeffc)
(cherry picked from commit e9fc20351b74be2d44c63f7bc3aeddb5a87b02f9)

Resolves: rhbz#2018245

src/pybind/mgr/cephadm/schedule.py

index d2924bce625c2b4fb44daa86a2a59facc873d8a7..3f5c5e6cfddd3d0904d75670e832f4ae5a3d28d6 100644 (file)
@@ -1,3 +1,4 @@
+import ipaddress
 import hashlib
 import logging
 import random
@@ -369,6 +370,13 @@ class HostAssignment(object):
     def find_ip_on_host(self, hostname: str, subnets: List[str]) -> Optional[str]:
         for subnet in subnets:
             ips: List[str] = []
+            # following is to allow loopback interfaces for both ipv4 and ipv6. Since we
+            # only have the subnet (and no IP) we assume default loopback IP address.
+            if ipaddress.ip_network(subnet).is_loopback:
+                if ipaddress.ip_network(subnet).version == 4:
+                    ips.append('127.0.0.1')
+                else:
+                    ips.append('::1')
             for iface, iface_ips in self.networks.get(hostname, {}).get(subnet, {}).items():
                 ips.extend(iface_ips)
             if ips: