]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: populate health metrics in beacon
authorJohn Spray <john.spray@redhat.com>
Wed, 27 Aug 2014 18:03:40 +0000 (19:03 +0100)
committerJohn Spray <john.spray@redhat.com>
Tue, 2 Sep 2014 13:06:25 +0000 (14:06 +0100)
Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/Beacon.cc
src/mds/Beacon.h
src/mds/MDS.cc

index b4a54e1862b8831d30447dec3c6bff7cf6148487..83a7efd1b1a8cb3fb88908e0f72b2ed9a8fbf808 100644 (file)
@@ -18,6 +18,8 @@
 
 #include "messages/MMDSBeacon.h"
 #include "mon/MonClient.h"
+#include "mds/MDS.h"
+#include "mds/MDLog.h"
 
 #include "Beacon.h"
 
@@ -166,8 +168,7 @@ void Beacon::_send()
 
   beacon->set_standby_for_rank(standby_for_rank);
   beacon->set_standby_for_name(standby_for_name);
-
-  // include _my_ feature set
+  beacon->set_health(health);
   beacon->set_compat(compat);
 
   monc->send_mon_message(beacon);
@@ -233,3 +234,31 @@ void Beacon::notify_want_state(MDSMap::DaemonState const newstate)
 }
 
 
+/**
+ * We are 'shown' an MDS briefly in order to update
+ * some health metrics that we will send in the next
+ * beacon.
+ */
+void Beacon::notify_health(MDS const *mds)
+{
+  Mutex::Locker l(lock);
+
+  // I'm going to touch this MDS, so it must be locked
+  assert(mds->mds_lock.is_locked_by_me());
+
+  health.metrics.clear();
+
+  // Detect MDS_HEALTH_TRIM condition
+  // Arbitrary factor of 2, indicates MDS is not trimming promptly
+  if (mds->mdlog->get_num_segments() > (size_t)(g_conf->mds_log_max_segments * 2)) {
+    std::ostringstream oss;
+    oss << "Behind on trimming (" << mds->mdlog->get_num_segments()
+      << "/" << g_conf->mds_log_max_segments << ")";
+
+    MDSHealthMetric m(MDS_HEALTH_TRIM, HEALTH_WARN, oss.str());
+    m.metadata["num_segments"] = mds->mdlog->get_num_segments();
+    m.metadata["max_segments"] = g_conf->mds_log_max_segments;
+    health.metrics.push_back(m);
+  }
+}
+
index 50d17dfd1c8f1676be309d2f867d57002b09c9ae..a9ac549d0c5850359c88b3c2c479779abdbf5772 100644 (file)
 #include "include/Context.h"
 #include "common/Mutex.h"
 #include "msg/Dispatcher.h"
+#include "messages/MMDSBeacon.h"
 
 class MonClient;
 class MMDSBeacon;
 class Message;
+class MDS;
 
 
 /**
@@ -58,6 +60,9 @@ class Beacon : public Dispatcher
   bool was_laggy;
   utime_t laggy_until;
 
+  // Health status to be copied into each beacon message
+  MDSHealth health;
+
   // Ticker
   class C_MDS_BeaconSender : public Context {
     Beacon *beacon;
@@ -87,6 +92,7 @@ public:
 
   void notify_mdsmap(MDSMap const *mdsmap);
   void notify_want_state(MDSMap::DaemonState const newstate);
+  void notify_health(MDS const *mds);
 
   void set_standby_for(int rank_, std::string const &name_);
 
index 37210f945d5aba517aabf407e50fdc65bd1295f7..53a8cfd42baca0526a0d2283ad86b4d4b907e2c8 100644 (file)
@@ -757,6 +757,9 @@ void MDS::tick()
       snapserver->check_osd_map(false);
   }
 
+  // Expose ourselves to Beacon to update health indicators
+  beacon.notify_health(this);
+
   check_ops_in_flight();
 }