]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add mon_health_preluminous_compat_warning
authorSage Weil <sage@redhat.com>
Tue, 8 Aug 2017 14:28:10 +0000 (10:28 -0400)
committerSage Weil <sage@redhat.com>
Wed, 9 Aug 2017 02:29:20 +0000 (22:29 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 7c22b46e907ad239fb9efaee96f3ef424beb220a)

src/common/options.cc
src/mon/Monitor.cc

index 67885f79d545c920c8dd049f86d726da66af9797..8027944a04196578fb2af5d4cff46504690106ab 100644 (file)
@@ -1177,7 +1177,11 @@ std::vector<Option> get_global_options() {
 
     Option("mon_health_preluminous_compat", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
     .set_default(false)
-    .set_description(""),
+    .set_description("Include health warnings in preluminous JSON fields"),
+
+    Option("mon_health_preluminous_compat_warning", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
+    .set_default(true)
+    .set_description("Warn about the health JSON format change in preluminous JSON fields"),
 
     Option("mon_health_max_detail", Option::TYPE_INT, Option::LEVEL_ADVANCED)
     .set_default(50)
index 06794ebabc3c52af5212c17b383f038c25842801..f0a2e0a1619dfbf9bcd78406433ce8ee6564c5d5 100644 (file)
@@ -2462,6 +2462,7 @@ health_status_t Monitor::get_health_status(
 {
   health_status_t r = HEALTH_OK;
   bool compat = g_conf->mon_health_preluminous_compat;
+  bool compat_warn = g_conf->get_val<bool>("mon_health_preluminous_compat_warning");
   if (f) {
     f->open_object_section("health");
     f->open_object_section("checks");
@@ -2487,25 +2488,37 @@ health_status_t Monitor::get_health_status(
     *plain += "\n";
   }
 
-  if (f && compat) {
-    f->open_array_section("summary");
-    for (auto& svc : paxos_service) {
-      svc->get_health_checks().dump_summary_compat(f);
+  if (f && (compat || compat_warn)) {
+    health_status_t cr = compat_warn ? min(HEALTH_WARN, r) : r;
+    if (compat) {
+      f->open_array_section("summary");
+      if (compat_warn) {
+       f->open_object_section("item");
+       f->dump_stream("severity") << HEALTH_WARN;
+       f->dump_string("summary", "'ceph health' JSON format has changed in luminous; update your health monitoring scripts");
+       f->close_section();
+      }
+      for (auto& svc : paxos_service) {
+       svc->get_health_checks().dump_summary_compat(f);
+      }
+      f->close_section();
     }
-    f->close_section();
-    f->dump_stream("overall_status") << r;
+    f->dump_stream("overall_status") << cr;
   }
 
   if (want_detail) {
-    if (f && compat) {
+    if (f && (compat || compat_warn)) {
       f->open_array_section("detail");
+      if (compat_warn) {
+       f->dump_string("item", "'ceph health' JSON format has changed in luminous. If you see this your monitoring system is scraping the wrong fields. Disable this with 'mon health preluminous compat warning = false'");
+      }
     }
 
     for (auto& svc : paxos_service) {
       svc->get_health_checks().dump_detail(f, plain, compat);
     }
 
-    if (f && compat) {
+    if (f && (compat || compat_warn)) {
       f->close_section();
     }
   }