]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: cull service daemons when the last instance has been removed
authorJason Dillaman <dillaman@redhat.com>
Wed, 27 Nov 2019 17:01:39 +0000 (12:01 -0500)
committerJason Dillaman <dillaman@redhat.com>
Mon, 9 Dec 2019 16:59:56 +0000 (11:59 -0500)
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 <dillaman@redhat.com>
(cherry picked from commit 7534737030b3b51e00f9ffc519574bcb10f6c950)

Conflicts:
src/mgr/DaemonServer.cc: uses older locks and DaemonKey is pair

src/mgr/DaemonServer.cc
src/mgr/DaemonState.cc
src/mgr/DaemonState.h

index da02925f0f92615be97bc62b0faff4a9e2832e6a..6364e58b1ecd9a96f5276d8aef3111b974e3855a 100644 (file)
@@ -2699,7 +2699,10 @@ void DaemonServer::got_service_map()
     });
 
   // cull missing daemons, populate new ones
+  std::set<std::string> types;
   for (auto& p : pending_service_map.services) {
+    types.insert(p.first);
+
     std::set<std::string> 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()
index b13685a1561b60adf415325a618dbd90a2170968..a276b395b38277aa4995e5f2ad60c9e9ee7e58e6 100644 (file)
@@ -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<std::string>& types_exist)
+{
+  std::set<DaemonKey> 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);
   }
 }
 
index 706286a2b12f8673d7035872bfae4ca197cd8223..0661f61a01ce17ded4e9347f757dab8c5070bc4e 100644 (file)
@@ -393,6 +393,7 @@ public:
    */
   void cull(const std::string& svc_name,
            const std::set<std::string>& names_exist);
+  void cull_services(const std::set<std::string>& types_exist);
 };
 
 #endif