]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: prevent podman from breaking socket.getfqdn()
authorSage Weil <sage@newdream.net>
Thu, 18 Mar 2021 18:26:48 +0000 (14:26 -0400)
committerSage Weil <sage@newdream.net>
Wed, 24 Mar 2021 22:03:51 +0000 (17:03 -0500)
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>
(cherry picked from commit cfc1f914ce74f1fd1f45e2efd3ba2ddcb2da129a)

src/cephadm/cephadm

index 238d4384ac22406189a80709e3dccb7401682729..7663c2a9155015ca7600b639ff5d9e9aa6a6d53d 100755 (executable)
@@ -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,