]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr: add a command "mgr report"
authorKefu Chai <kchai@redhat.com>
Wed, 17 May 2017 07:30:28 +0000 (15:30 +0800)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 17:02:46 +0000 (13:02 -0400)
* extract send_report() out of tick() so it can be reused.
* add a commmand "mgr report-mon" for mgr, so we are able to flush the
  the mgr stats to mon actively without waiting for the tick. this
  could help with the tests.

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/workunits/cephtool/test.sh
src/messages/MMonMgrReport.h
src/mgr/ClusterState.cc
src/mgr/ClusterState.h
src/mgr/DaemonServer.cc
src/mgr/DaemonServer.h
src/mgr/Mgr.cc

index c67e7a6de49a281c46032ff0cea83635ecae10e8..3938b133709b0d334e92c03e5059c1ca172fff10 100755 (executable)
@@ -337,8 +337,7 @@ function test_tiering_1()
   # test with dirty objects in the tier pool
   # tier pool currently set to 'writeback'
   rados -p cache put /etc/passwd /etc/passwd
-  ceph tell osd.\* flush_pg_stats || true
-  ceph tell mgr mgr report-mon
+  flush_pg_stats
   # 1 dirty object in pool 'cache'
   ceph osd tier cache-mode cache proxy
   expect_false ceph osd tier cache-mode cache none
@@ -347,8 +346,7 @@ function test_tiering_1()
   # remove object from tier pool
   rados -p cache rm /etc/passwd
   rados -p cache cache-flush-evict-all
-  ceph tell osd.\* flush_pg_stats || true
-  ceph tell mgr mgr report-mon
+  flush_pg_stats
   # no dirty objects in pool 'cache'
   ceph osd tier cache-mode cache proxy
   ceph osd tier cache-mode cache none
@@ -497,8 +495,7 @@ function test_tiering_8()
   rados -p cache4 put foo1 $tmpfile
   rados -p cache4 put foo2 $tmpfile
   rm -f $tmpfile
-  ceph tell osd.\* flush_pg_stats || true
-  ceph tell mgr mgr report-mon
+  flush_pg_stats
   ceph df | grep datapool | grep ' 2 '
   ceph osd tier remove-overlay datapool
   ceph osd tier remove datapool cache4
index 593bfc0e87341a9e806ebb537a8a047b0a569675..bf91519eb5c2e8f23b4efc2e41e4be73baf90b9e 100644 (file)
@@ -17,7 +17,6 @@
 
 #include "messages/PaxosServiceMessage.h"
 #include "include/types.h"
-#include "mon/PGMap.h"
 
 // health_status_t
 static inline void encode(health_status_t hs, bufferlist& bl) {
@@ -46,7 +45,6 @@ private:
   ~MMonMgrReport() override {}
 
 public:
-  bool needs_send = false;
   const char *get_type_name() const override { return "monmgrreport"; }
 
   void print(ostream& out) const override {
index 3ec59c170787470055656e989e4441b272093707..c40df895ef1f0b0a228462c1fd8e5b27ee680404 100644 (file)
@@ -113,19 +113,3 @@ void ClusterState::notify_osdmap(const OSDMap &osd_map)
   // that a cut-down set of functionality remains in PGMonitor
   // while the full-blown PGMap lives only here.
 }
-
-void ClusterState::tick(MMonMgrReport *m)
-{
-  dout(10) << __func__ << dendl;
-  // FIXME: no easy way to get mon features here.  this will do for
-  // now, though, as long as we don't make a backward-incompat change.
-  pg_map.encode_digest(m->get_data(), CEPH_FEATURES_ALL);
-
-  // FIXME: reporting health detail here might be a bad idea?
-  with_osdmap([&](const OSDMap& osdmap) {
-      pg_map.get_health(g_ceph_context, osdmap,
-                       m->health_summary,
-                       &m->health_detail);
-    });
-  m->needs_send = true;
-}
index 72643dba20b1f1e955c455c3da7c202b300db94d..ca7deddaea118ea6fc84ff8a7d81047f886c6648 100644 (file)
@@ -58,8 +58,6 @@ public:
 
   void notify_osdmap(const OSDMap &osd_map);
 
-  void tick(MMonMgrReport *m);
-
   bool have_fsmap() const {
     Mutex::Locker l(lock);
     return fsmap.get_epoch() > 0;
index ac23a9f90287959a1375b38b70752dd2cce324e8..2a35f7a5b1c9249158e4ef59abfbea9a881346cc 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "messages/MMgrOpen.h"
 #include "messages/MMgrConfigure.h"
+#include "messages/MMonMgrReport.h"
 #include "messages/MCommand.h"
 #include "messages/MCommandReply.h"
 #include "messages/MPGStats.h"
@@ -725,3 +726,23 @@ bool DaemonServer::handle_command(MCommand *m)
     return true;
   }
 }
+
+void DaemonServer::send_report()
+{
+  auto m = new MMonMgrReport();
+  cluster_state.with_pgmap([&](const PGMap& pg_map) {
+      // FIXME: no easy way to get mon features here.  this will do for
+      // now, though, as long as we don't make a backward-incompat change.
+      pg_map.encode_digest(m->get_data(), CEPH_FEATURES_ALL);
+      // FIXME: reporting health detail here might be a bad idea?
+      cluster_state.with_osdmap([&](const OSDMap& osdmap) {
+         pg_map.get_health(g_ceph_context, osdmap,
+                           m->health_summary,
+                           &m->health_detail);
+       });
+    });
+  // TODO? We currently do not notify the PyModules
+  // TODO: respect needs_send, so we send the report only if we are asked to do
+  //       so, or the state is updated.
+  monc->send_mon_message(m);
+}
index 66b8045c8f0c0cebe1d22844d485cda339255422..bf6261356ce073dd7cdb02fcaf23a0885d39abe0 100644 (file)
@@ -112,7 +112,7 @@ public:
   bool handle_open(MMgrOpen *m);
   bool handle_report(MMgrReport *m);
   bool handle_command(MCommand *m);
-  void tick(MMonMgrReport *m) {}
+  void send_report();
 };
 
 #endif
index 158a8ac1a5200101fcf647a2df0b7c0cc5af9c6f..cbc443f3a32968ca705510ebfc71c8315950377b 100644 (file)
@@ -27,7 +27,6 @@
 #include "DaemonServer.h"
 #include "messages/MMgrBeacon.h"
 #include "messages/MMgrDigest.h"
-#include "messages/MMonMgrReport.h"
 #include "messages/MCommand.h"
 #include "messages/MCommandReply.h"
 #include "messages/MLog.h"
@@ -587,11 +586,5 @@ void Mgr::handle_mgr_digest(MMgrDigest* m)
 void Mgr::tick()
 {
   dout(0) << __func__ << dendl;
-  MMonMgrReport *m = new MMonMgrReport();
-  cluster_state.tick(m);
-  server.tick(m);
-  // TODO? We currently do not notify the PyModules
-  if (m->needs_send) {
-    monc->send_mon_message(m);
-  }
+  server.send_report();
 }