]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/HealthMonitor: fix mon_warn_on_osd_down_out_interval_zero does not work
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 19 Jul 2017 09:10:29 +0000 (17:10 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 19 Jul 2017 09:40:20 +0000 (17:40 +0800)
And the output is wrong...

cluster:
    id:     b979e20d-6441-46b4-8663-954e1e8ce01d
    health: HEALTH_WARN
            1 osds down
            mon %names has mon_osd_down_out_interval set to 0

Now:
 health: HEALTH_WARN
            mon a is low on available space
            mon a has mon_osd_down_out_interval set to 0

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/mon/HealthMonitor.cc

index 3efcd840109658b1395abc6588da3246e953d496..35e52f4f99699c33894ffc126fe70c884fc4af00 100644 (file)
@@ -123,7 +123,8 @@ void HealthMonitor::encode_pending(MonitorDBStore::TransactionRef t)
   for (auto &p : pending_health.checks) {
     p.second.summary = boost::regex_replace(
       p.second.summary,
-      boost::regex("%num%"), stringify(names[p.first].size()));
+      boost::regex("%hasorhave%"),
+      names[p.first].size() > 1 ? "have" : "has");
     p.second.summary = boost::regex_replace(
       p.second.summary,
       boost::regex("%names%"), stringify(names[p.first]));
@@ -252,20 +253,6 @@ bool HealthMonitor::check_member_health()
     d.detail.push_back(ss2.str());
   }
 
-  auto p = quorum_checks.find(mon->rank);
-  if (p == quorum_checks.end() ||
-      p->second != next) {
-    if (mon->is_leader()) {
-      // prepare to propose
-      quorum_checks[mon->rank] = next;
-      changed = true;
-    } else {
-      // tell the leader
-      mon->messenger->send_message(new MMonHealthChecks(next),
-                                  mon->monmap->get_inst(mon->get_leader()));
-    }
-  }
-
   // OSD_NO_DOWN_OUT_INTERVAL
   {
     // Warn if 'mon_osd_down_out_interval' is set to zero.
@@ -283,13 +270,27 @@ bool HealthMonitor::check_member_health()
     if (g_conf->mon_warn_on_osd_down_out_interval_zero &&
         g_conf->mon_osd_down_out_interval == 0) {
       ostringstream ss, ds;
-      ss << "mon%plurals% %names %hasorhave% mon_osd_down_out_interval set to 0";
+      ss << "mon%plurals% %names% %hasorhave% mon_osd_down_out_interval set to 0";
       auto& d = next.add("OSD_NO_DOWN_OUT_INTERVAL", HEALTH_WARN, ss.str());
       ds << "mon." << mon->name << " has mon_osd_down_out_interval set to 0";
       d.detail.push_back(ds.str());
     }
   }
 
+  auto p = quorum_checks.find(mon->rank);
+  if (p == quorum_checks.end() ||
+      p->second != next) {
+    if (mon->is_leader()) {
+      // prepare to propose
+      quorum_checks[mon->rank] = next;
+      changed = true;
+    } else {
+      // tell the leader
+      mon->messenger->send_message(new MMonHealthChecks(next),
+                                  mon->monmap->get_inst(mon->get_leader()));
+    }
+  }
+
   return changed;
 }