From 60ebc275120ead7d1ffa388b145caeb5969fa702 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 18 Mar 2021 14:26:48 -0400 Subject: [PATCH] cephadm: prevent podman from breaking socket.getfqdn() socket.getfqdn() will return the reverse lookup for 127.0.1.1, which is the last item listed for that IP in /etc/hosts. Podman, by default, will append the container name (ceph-$fsid-$name) to that line, which is not a valid hostname, and not what we want the dashbaord to use for the URI it advertises in the service map. Pass --no-hosts to podman to disable this. Docker does not appear to modify /etc/hosts by default--or, more importantly, does not add the container name there. Explicitly instruct podman (and docker) to add a Fixes: https://tracker.ceph.com/issues/49890 Signed-off-by: Sage Weil (cherry picked from commit cfc1f914ce74f1fd1f45e2efd3ba2ddcb2da129a) --- src/cephadm/cephadm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 238d4384ac224..7663c2a915501 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -3039,9 +3039,13 @@ class CephContainer: '--ipc=host', ] - if 'podman' in self.ctx.container_path and \ - os.path.exists('/etc/ceph/podman-auth.json'): - cmd_args.append('--authfile=/etc/ceph/podman-auth.json') + if 'podman' in self.ctx.container_path: + # podman adds the container *name* to /etc/hosts (for 127.0.1.1) + # by default, which makes python's socket.getfqdn() return that + # instead of a valid hostname. + cmd_args.append('--no-hosts') + if os.path.exists('/etc/ceph/podman-auth.json'): + cmd_args.append('--authfile=/etc/ceph/podman-auth.json') envs: List[str] = [ '-e', 'CONTAINER_IMAGE=%s' % self.image, -- 2.39.5