From: Redouane Kachach Date: Fri, 26 Aug 2022 12:00:05 +0000 (+0200) Subject: mgr/cephadm: allow binding to loopback for rgw daemons X-Git-Tag: v17.2.4~25^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F47951%2Fhead;p=ceph.git mgr/cephadm: allow binding to loopback for rgw daemons Fixes: https://tracker.ceph.com/issues/57304 Signed-off-by: Redouane Kachach (cherry picked from commit 1a722f35c1f40353dbdf06fdb63364822ebaeffc) --- diff --git a/src/pybind/mgr/cephadm/schedule.py b/src/pybind/mgr/cephadm/schedule.py index 5002ec6e5060..8049a042ee9b 100644 --- a/src/pybind/mgr/cephadm/schedule.py +++ b/src/pybind/mgr/cephadm/schedule.py @@ -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: