]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: keep per-module checks, and report them back to the mon
authorSage Weil <sage@redhat.com>
Fri, 21 Jul 2017 17:29:47 +0000 (13:29 -0400)
committerSage Weil <sage@redhat.com>
Tue, 25 Jul 2017 16:29:20 +0000 (12:29 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/DaemonServer.cc
src/mgr/MgrPyModule.cc
src/mgr/MgrPyModule.h
src/mgr/PyModules.cc
src/mgr/PyModules.h

index dc9837cac82ea6a3a7f4fc18e796a85720723676..a58675ed24c071b5e38ad48db43958f59fda8e7e 100644 (file)
@@ -1169,6 +1169,8 @@ void DaemonServer::send_report()
   }
 
   auto m = new MMonMgrReport();
+  py_modules.get_health_checks(&m->health_checks);
+
   cluster_state.with_pgmap([&](const PGMap& pg_map) {
       cluster_state.update_delta_stats();
 
@@ -1191,6 +1193,7 @@ void DaemonServer::send_report()
 
          pg_map.get_health_checks(g_ceph_context, osdmap,
                                   &m->health_checks);
+
          dout(10) << m->health_checks.checks.size() << " health checks"
                   << dendl;
          dout(20) << "health checks:\n";
index fda9bf6528dbd90500cad04bb4569d069b9f6be0..a2bf73ca379124c26f2d534efae35a0a884e2e8c 100644 (file)
@@ -365,3 +365,7 @@ int MgrPyModule::handle_command(
   return r;
 }
 
+void MgrPyModule::get_health_checks(health_check_map_t *checks)
+{
+  checks->merge(health_checks);
+}
index 14be1566f069512890360b0f03b44080b60937f4..6eea29eee24e6abbbd2dcc9e32aeae326f337d7a 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "common/cmdparse.h"
 #include "common/LogEntry.h"
+#include "common/Mutex.h"
+#include "mon/health_check.h"
 
 #include <vector>
 #include <string>
@@ -47,6 +49,8 @@ private:
   PyThreadState *pMainThreadState;
   PyThreadState *pMyThreadState = nullptr;
 
+  health_check_map_t health_checks;
+
   std::vector<ModuleCommand> commands;
 
   int load_commands();
@@ -75,6 +79,11 @@ public:
     const cmdmap_t &cmdmap,
     std::stringstream *ds,
     std::stringstream *ss);
+
+  void set_health_checks(health_check_map_t&& c) {
+    health_checks = std::move(c);
+  }
+  void get_health_checks(health_check_map_t *checks);
 };
 
 std::string handle_pyerror();
index 74628dbbf1c7b8f71fbf86c5920b7f9fb71f1d0f..e95bec8d75d17e52b5efacee46dcfe776930b554 100644 (file)
@@ -800,3 +800,21 @@ void PyModules::list_modules(std::set<std::string> *modules)
 {
   _list_modules(g_conf->mgr_module_path, modules);
 }
+
+void PyModules::set_health_checks(const std::string& handle,
+                                 health_check_map_t&& checks)
+{
+  Mutex::Locker l(lock);
+  auto p = modules.find(handle);
+  if (p != modules.end()) {
+    p->second->set_health_checks(std::move(checks));
+  }
+}
+
+void PyModules::get_health_checks(health_check_map_t *checks)
+{
+  Mutex::Locker l(lock);
+  for (auto& p : modules) {
+    p.second->get_health_checks(checks);
+  }
+}
index 1c6751f4e51b936114f05e02a8087cbb5144011d..431abec76f0e3cf4b814ed51239dc5d7feb99a46 100644 (file)
@@ -30,6 +30,7 @@
 #include "ClusterState.h"
 
 class ServeThread;
+class health_check_map_t;
 
 class PyModules
 {
@@ -115,6 +116,10 @@ public:
   void set_config(const std::string &handle,
       const std::string &key, const std::string &val);
 
+  void set_health_checks(const std::string& handle,
+                        health_check_map_t&& checks);
+  void get_health_checks(health_check_map_t *checks);
+
   void log(const std::string &handle,
            int level, const std::string &record);