From 1a5288357e6d20645f581920fd90af7e3070c98b Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 27 Nov 2019 09:32:28 -0500 Subject: [PATCH] mgr: ensure new daemons are properly indexed by hostname The hostname key was never populated when storing a daemon within the daemon state index for the first time. This results in the "by_server" index being incorrect. Signed-off-by: Jason Dillaman (cherry picked from commit 3e7bc80b35b43d495a56b9cb0e9e15f58381f77b) --- src/mgr/DaemonServer.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 0bb21d8587d4d..da02925f0f926 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -425,6 +425,7 @@ bool DaemonServer::handle_open(MMgrOpen *m) DaemonStatePtr daemon; if (daemon_state.exists(key)) { + dout(20) << "updating existing DaemonState for " << key << dendl; daemon = daemon_state.get(key); } if (m->service_daemon && !daemon) { @@ -435,12 +436,16 @@ bool DaemonServer::handle_open(MMgrOpen *m) daemon_state.insert(daemon); } if (daemon) { - dout(20) << "updating existing DaemonState for " << m->daemon_name << dendl; + if (m->service_daemon) { + // update the metadata through the daemon state index to + // ensure it's kept up-to-date + daemon_state.update_metadata(daemon, m->daemon_metadata); + } + std::lock_guard l(daemon->lock); daemon->perf_counters.clear(); if (m->service_daemon) { - daemon->set_metadata(m->daemon_metadata); daemon->service_status = m->daemon_status; utime_t now = ceph_clock_now(); -- 2.39.5