]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: prevent podman from breaking socket.getfqdn() 40223/head
authorSage Weil <sage@newdream.net>
Thu, 18 Mar 2021 18:26:48 +0000 (14:26 -0400)
committerSage Weil <sage@newdream.net>
Thu, 18 Mar 2021 18:26:48 +0000 (14:26 -0400)
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 <sage@newdream.net>
src/cephadm/cephadm

index 75be85f3c6dd27795861a44b907b27da0bee4d00..939a6f62951d9d659f46dd8fc2933067d1c19163 100755 (executable)
@@ -3036,9 +3036,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,