]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/HealthMonitor: simplify health alert dump
authorSage Weil <sage@redhat.com>
Wed, 31 Jul 2019 08:24:45 +0000 (03:24 -0500)
committerSage Weil <sage@redhat.com>
Thu, 15 Aug 2019 01:40:08 +0000 (20:40 -0500)
Use dump() member instead of duplicating!  The only reason we had this
before was because the detail portion was optinoal

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/HealthMonitor.cc
src/mon/health_check.h

index 7c51e025baa28672b4659633cce31df2127c4272..18600acbe258f935c702964252db4482b56de416 100644 (file)
@@ -459,20 +459,8 @@ health_status_t HealthMonitor::get_health_status(
     f->open_object_section("checks");
     for (auto& p : all.checks) {
       f->open_object_section(p.first.c_str());
-      f->dump_stream("severity") << p.second.severity;
+      p.second.dump(f, want_detail);
       f->dump_bool("muted", mutes.count(p.first));
-      f->open_object_section("summary");
-      f->dump_string("message", p.second.summary);
-      f->close_section();
-      if (want_detail) {
-       f->open_array_section("detail");
-       for (auto& d : p.second.detail) {
-         f->open_object_section("detail_item");
-         f->dump_string("message", d);
-         f->close_section();
-       }
-       f->close_section();
-      }
       f->close_section();
     }
     f->close_section();
index 93b9e62f9b08b33a2c53befa27326664760e4ef2..4215a8bdbcace13ac6431340d99e2b3e10f947ba 100644 (file)
@@ -34,20 +34,22 @@ struct health_check_t {
     return !(l == r);
   }
 
-  void dump(ceph::Formatter *f) const {
+  void dump(ceph::Formatter *f, bool want_detail=true) const {
     f->dump_stream("severity") << severity;
 
     f->open_object_section("summary");
     f->dump_string("message", summary);
     f->close_section();
 
-    f->open_array_section("detail");
-    for (auto& p : detail) {
-      f->open_object_section("detail_item");
-      f->dump_string("message", p);
+    if (want_detail) {
+      f->open_array_section("detail");
+      for (auto& p : detail) {
+       f->open_object_section("detail_item");
+       f->dump_string("message", p);
+       f->close_section();
+      }
       f->close_section();
     }
-    f->close_section();
   }
 
   static void generate_test_instances(std::list<health_check_t*>& ls) {