]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr/cephadm/inventory: do not try to resolve current mgr host
authorSage Weil <sage@newdream.net>
Thu, 3 Jun 2021 14:29:00 +0000 (10:29 -0400)
committerSage Weil <sage@newdream.net>
Fri, 4 Jun 2021 02:05:20 +0000 (21:05 -0500)
commit4330cad30735781a9bc23150286c01406529f56b
tree32d85b437507b907418cc2ad9436aac3c7d514ed
parent9fe6382e8b37aaad4d0af8f7eb5c254225e96f34
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>
(cherry picked from commit 45e806676bc9bf85d4947eba9741387cec3ae2fd)
src/pybind/mgr/cephadm/inventory.py