]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: send osd-beacon to mon periodically
authorKefu Chai <kchai@redhat.com>
Sat, 11 Mar 2017 09:51:13 +0000 (17:51 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 30 Mar 2017 12:21:17 +0000 (20:21 +0800)
add an option named "osd_beacon_report_interval" to specify the interval
to send osd-beacon.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/config_opts.h
src/osd/OSD.cc
src/osd/OSD.h

index 8c22e3837824dc8af32acee3028a5d39d5d4a077..cadcff155c404a8962fa7ef479ab2fb24d62c063 100644 (file)
@@ -789,6 +789,7 @@ OPTION(osd_mon_heartbeat_interval, OPT_INT, 30)  // (seconds) how often to ping
 OPTION(osd_mon_report_interval_max, OPT_INT, 600)
 OPTION(osd_mon_report_interval_min, OPT_INT, 5)  // pg stats, failures, up_thru, boot.
 OPTION(osd_mon_report_max_in_flight, OPT_INT, 2)  // max updates in flight
+OPTION(osd_beacon_report_interval, OPT_INT, 300)       // (second) how often to send beacon message to monitor
 OPTION(osd_pg_stat_report_interval_max, OPT_INT, 500)  // report pg stats for any given pg at least this often
 OPTION(osd_mon_ack_timeout, OPT_DOUBLE, 30.0) // time out a mon if it doesn't ack stats
 OPTION(osd_stats_ack_timeout_factor, OPT_DOUBLE, 2.0) // multiples of mon_ack_timeout
index 6f8d51f2acc9a7bfd6d312784377155efc2285c3..e7358ccd0b87225a5fa441db1a7064887d5b90d7 100644 (file)
@@ -68,6 +68,7 @@
 #include "messages/MOSDOp.h"
 #include "messages/MOSDOpReply.h"
 #include "messages/MOSDBackoff.h"
+#include "messages/MOSDBeacon.h"
 #include "messages/MOSDRepOp.h"
 #include "messages/MOSDRepOpReply.h"
 #include "messages/MOSDSubOp.h"
@@ -4514,6 +4515,15 @@ void OSD::tick()
   do_waiters();
 
   tick_timer.add_event_after(OSD_TICK_INTERVAL, new C_Tick(this));
+
+  if (is_active()) {
+    const auto now = ceph::coarse_mono_clock::now();
+    const auto elapsed = now - last_sent_beacon;
+    if (chrono::duration_cast<chrono::seconds>(elapsed).count() >
+       cct->_conf->osd_beacon_report_interval) {
+      send_beacon(now);
+    }
+  }
 }
 
 void OSD::tick_without_osd_lock()
@@ -4964,6 +4974,7 @@ void OSD::ms_handle_connect(Connection *con)
       send_pg_stats(now);
 
       map_lock.put_read();
+      send_beacon(ceph::coarse_mono_clock::now());
     }
 
     // full map requests may happen while active or pre-boot
@@ -5538,6 +5549,19 @@ void OSD::flush_pg_stats()
   osd_lock.Lock();
 }
 
+void OSD::send_beacon(const ceph::coarse_mono_clock::time_point& now)
+{
+  dout(20) << __func__ << dendl;
+  last_sent_beacon = now;
+  const auto& monmap = monc->monmap;
+  // send beacon to mon even if we are just connected, and the monmap is not
+  // initialized yet by then.
+  if (monmap.epoch == 0 &&
+      monmap.get_required_features().contains_all(
+        ceph::features::mon::FEATURE_LUMINOUS)) {
+    monc->send_mon_message(new MOSDBeacon());
+  }
+}
 
 void OSD::handle_command(MMonCommand *m)
 {
index 8ec611cd34f35b2c4ff3f59e9ef3fe7ea435e906..f1d107283a6a90de0aa80b31c0ee82e9935e2795 100644 (file)
@@ -2131,6 +2131,9 @@ protected:
   void handle_pg_stats_ack(class MPGStatsAck *ack);
   void flush_pg_stats();
 
+  ceph::coarse_mono_clock::time_point last_sent_beacon;
+  void send_beacon(const ceph::coarse_mono_clock::time_point& now);
+
   void pg_stat_queue_enqueue(PG *pg) {
     pg_stat_queue_lock.Lock();
     if (pg->is_primary() && !pg->stat_queue_item.is_on_list()) {