]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: set hostname propery on ServiceMap services
authorJohn Spray <john.spray@redhat.com>
Mon, 26 Jun 2017 23:42:34 +0000 (19:42 -0400)
committerSage Weil <sage@redhat.com>
Sun, 9 Jul 2017 18:09:05 +0000 (14:09 -0400)
Signed-off-by: John Spray <john.spray@redhat.com>
src/mgr/DaemonServer.cc

index 53dce6db95533c917c7d05d5cc205a5e1dd27e7d..7b9086c4800dd4ad474ed538dcbb097e4d97245c 100644 (file)
@@ -287,8 +287,10 @@ bool DaemonServer::handle_open(MMgrOpen *m)
     } else {
       dout(4) << "constructing new DaemonState for " << key << dendl;
       daemon = std::make_shared<DaemonState>(daemon_state.types);
-      // FIXME: crap, we don't know the hostname at this stage.
       daemon->key = key;
+      if (m->daemon_metadata.count("hostname")) {
+        daemon->hostname = m->daemon_metadata["hostname"];
+      }
       daemon_state.insert(daemon);
     }
     daemon->service_daemon = true;
@@ -345,7 +347,9 @@ bool DaemonServer::handle_report(MMgrReport *m)
     // FIXME: crap, we don't know the hostname at this stage.
     daemon->key = key;
     daemon_state.insert(daemon);
-    // FIXME: we should request metadata at this stage
+    // FIXME: we should avoid this case by rejecting MMgrReport from
+    // daemons without sessions, and ensuring that session open
+    // always contains metadata.
   }
   assert(daemon != nullptr);
   auto &daemon_counters = daemon->perf_counters;
@@ -1031,9 +1035,12 @@ void DaemonServer::got_service_map()
       if (!daemon_state.exists(key)) {
        auto daemon = std::make_shared<DaemonState>(daemon_state.types);
        daemon->key = key;
-       daemon_state.insert(daemon);
        daemon->metadata = q.second.metadata;
+        if (q.second.metadata.count("hostname")) {
+          daemon->hostname = q.second.metadata["hostname"];
+        }
        daemon->service_daemon = true;
+       daemon_state.insert(daemon);
        dout(10) << "added missing " << key << dendl;
       }
     }