]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
mgr/cephadm/inventory: do not try to resolve current mgr host 41636/head
authorSage Weil <sage@newdream.net>
Thu, 3 Jun 2021 14:29:00 +0000 (10:29 -0400)
committerSage Weil <sage@newdream.net>
Thu, 3 Jun 2021 16:11:31 +0000 (12:11 -0400)
commit45e806676bc9bf85d4947eba9741387cec3ae2fd
tree894054e3186dee2ad8b3f0a95900c6c64964806a
parent72d72fc5db33110effdbfcdfd19e086d4dd831be
mgr/cephadm/inventory: do not try to resolve current mgr host

The CNI configuration may set up a private network for the container, which
is mapped to the hostname in /etc/hosts.  For example, my test box sets
up 10.88.0.0/24 because I was using crio + kubeadm on this host earlier
(at least I think that's why):

$ sudo podman run --rm --name test123 --entrypoint /bin/bash -it quay.ceph.io/ceph-ci/ceph:master -c "cat /etc/hosts"
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.88.0.8 f9e91bf2478f test123

In any case, we should never trust a lookup of our own hostname from inside
a container!

This isn't quite sufficient, though: if this is a single-host cluster, then
we fall back to using get_mgr_ip(). That value may be distorted by the
public_network option on the mgr, but we don't have any other good
options here, and single-node clusters are unlikely to have complex
network configs.

Refactor a bit to avoid the try/except nesting.

Signed-off-by: Sage Weil <sage@newdream.net>
src/pybind/mgr/cephadm/inventory.py