]> 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>
Wed, 27 Nov 2019 17:01:39 +0000 (12:01 -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>
src/mgr/DaemonServer.cc
src/mgr/DaemonState.cc
src/mgr/DaemonState.h

index 7738c38067973d6a6e0f0ad8b60d2d6ce486c5b1..f7a7badaa51ed3a09855dd02ac5bed0060893845 100644 (file)
@@ -2746,7 +2746,10 @@ void DaemonServer::got_service_map()
     });
 
   // cull missing daemons, populate new ones
+  std::set<std::string> types;
   for (auto& [type, service] : pending_service_map.services) {
+    types.insert(type);
+
     std::set<std::string> names;
     for (auto& q : service.daemons) {
       names.insert(q.first);
@@ -2762,6 +2765,7 @@ void DaemonServer::got_service_map()
     }
     daemon_state.cull(type, names);
   }
+  daemon_state.cull_services(types);
 }
 
 void DaemonServer::got_mgr_map()
index de519a2b9211bc06a65a2f0e6a766420dac86e00..13e42ff10069fcc56c6101efa84ee80e6c00b207 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;
+
+  std::unique_lock 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.type) == 0) {
+      victims.insert(daemon_key);
+    }
+  }
+
   for (auto &i : victims) {
     dout(4) << "Removing data for " << i << dendl;
-    _erase({svc_name, i});
+    _erase(i);
   }
 }
 
index 3a0c13b712ef6c0be4021721c4c0231db1dc3b93..1d374b225ea3792d2181fb463f745cf831d19701 100644 (file)
@@ -387,6 +387,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