From 2f720a42fca22ec0023e6085276193b0ca822a1c Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 26 Jun 2017 19:42:34 -0400 Subject: [PATCH] mgr: set hostname propery on ServiceMap services Signed-off-by: John Spray --- src/mgr/DaemonServer.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 53dce6db95533..7b9086c4800dd 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -287,8 +287,10 @@ bool DaemonServer::handle_open(MMgrOpen *m) } else { dout(4) << "constructing new DaemonState for " << key << dendl; daemon = std::make_shared(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(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; } } -- 2.39.5