From: Sage Weil Date: Wed, 11 May 2016 13:22:02 +0000 (-0400) Subject: crush/CrushLocation: use short hostname X-Git-Tag: v11.0.0~471^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7d61564f53c9764b056ee4ce86842eb7e2557240;p=ceph.git crush/CrushLocation: use short hostname This matches the previous ceph-osd-prestart.sh behavior, which called ceph-crush-location, which calls 'hostname -s'. Fixes: http://tracker.ceph.com/issues/15840 Signed-off-by: Sage Weil --- diff --git a/src/crush/CrushLocation.cc b/src/crush/CrushLocation.cc index 5a32c436935..de648bc6241 100644 --- a/src/crush/CrushLocation.cc +++ b/src/crush/CrushLocation.cc @@ -96,6 +96,13 @@ int CrushLocation::init_on_startup() int r = gethostname(hostname, sizeof(hostname)-1); if (r < 0) strcpy(hostname, "unknown_host"); + // use short hostname + for (unsigned i=0; hostname[i]; ++i) { + if (hostname[i] == '.') { + hostname[i] = '\0'; + break; + } + } std::lock_guard l(lock); loc.clear(); loc.insert(make_pair("host", hostname));