From 9904f48fda9ebb5ee0f7885bff2b16f71f500aed Mon Sep 17 00:00:00 2001 From: Redouane Kachach Date: Fri, 26 Aug 2022 14:00:05 +0200 Subject: [PATCH] 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) (cherry picked from commit e9fc20351b74be2d44c63f7bc3aeddb5a87b02f9) Resolves: rhbz#2018245 --- src/pybind/mgr/cephadm/schedule.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pybind/mgr/cephadm/schedule.py b/src/pybind/mgr/cephadm/schedule.py index d2924bce625c2..3f5c5e6cfddd3 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 @@ -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: -- 2.39.5