]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushLocation: use short hostname
authorSage Weil <sage@redhat.com>
Wed, 11 May 2016 13:22:02 +0000 (09:22 -0400)
committerSage Weil <sage@redhat.com>
Wed, 11 May 2016 13:27:41 +0000 (09:27 -0400)
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 <sage@redhat.com>
src/crush/CrushLocation.cc

index 5a32c4369359ae1f0992612d4c1c9983ab1b0dff..de648bc6241d099c0d3e447867a88c486e5acf27 100644 (file)
@@ -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<std::mutex> l(lock);
   loc.clear();
   loc.insert(make_pair<std::string,std::string>("host", hostname));