From: Jason Dillaman Date: Wed, 27 Nov 2019 17:01:39 +0000 (-0500) Subject: mgr: cull service daemons when the last instance has been removed X-Git-Tag: v14.2.8~20^2~70^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3166cd86bf636075c9c218498d7754202930a2e7;p=ceph.git mgr: cull service daemons when the last instance has been removed Previously, when the last daemon of a given service was stopped, it would not have been removed from the MGR internal service daemon collection. This would result in "ceph service dump" not showing the service but the dashboard would incorrectly show it. Signed-off-by: Jason Dillaman (cherry picked from commit 7534737030b3b51e00f9ffc519574bcb10f6c950) Conflicts: src/mgr/DaemonServer.cc: uses older locks and DaemonKey is pair --- diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index da02925f0f92..6364e58b1ecd 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -2699,7 +2699,10 @@ void DaemonServer::got_service_map() }); // cull missing daemons, populate new ones + std::set types; for (auto& p : pending_service_map.services) { + types.insert(p.first); + std::set names; for (auto& q : p.second.daemons) { names.insert(q.first); @@ -2715,6 +2718,7 @@ void DaemonServer::got_service_map() } daemon_state.cull(p.first, names); } + daemon_state.cull_services(types); } void DaemonServer::got_mgr_map() diff --git a/src/mgr/DaemonState.cc b/src/mgr/DaemonState.cc index b13685a1561b..a276b395b382 100644 --- a/src/mgr/DaemonState.cc +++ b/src/mgr/DaemonState.cc @@ -258,9 +258,29 @@ void DaemonStateIndex::cull(const std::string& svc_name, } } + for (auto &i : victims) { + DaemonKey daemon_key{svc_name, i}; + dout(4) << "Removing data for " << daemon_key << dendl; + _erase(daemon_key); + } +} + +void DaemonStateIndex::cull_services(const std::set& types_exist) +{ + std::set victims; + + RWLock::WLocker l(lock); + for (auto it = all.begin(); it != all.end(); ++it) { + const auto& daemon_key = it->first; + if (it->second->service_daemon && + types_exist.count(daemon_key.first) == 0) { + victims.insert(daemon_key); + } + } + for (auto &i : victims) { dout(4) << "Removing data for " << i << dendl; - _erase({svc_name, i}); + _erase(i); } } diff --git a/src/mgr/DaemonState.h b/src/mgr/DaemonState.h index 706286a2b12f..0661f61a01ce 100644 --- a/src/mgr/DaemonState.h +++ b/src/mgr/DaemonState.h @@ -393,6 +393,7 @@ public: */ void cull(const std::string& svc_name, const std::set& names_exist); + void cull_services(const std::set& types_exist); }; #endif