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

src/pybind/mgr/cephadm/schedule.py

index 5002ec6e5060e66f71c378f8e574bb8639384ec1..8049a042ee9ba64ba3527b6c286a88d8d6965644 100644 (file)
@@ -1,3 +1,4 @@
+import ipaddress
 import hashlib
 import logging
 import random
@@ -359,6 +360,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: