]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: send beacon to mon periodically
authorKefu Chai <kchai@redhat.com>
Mon, 14 Jan 2019 09:48:18 +0000 (17:48 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 18 Jan 2019 04:42:08 +0000 (12:42 +0800)
so monitor won't mark crimson-osd down and out

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

index afde4ef1ddeb70a6104aa3d0fca4d759c742f95c..e51182eeccc29e44d743226a7f82fe26475071d3 100644 (file)
@@ -1,5 +1,6 @@
 #include "osd.h"
 
+#include "messages/MOSDBeacon.h"
 #include "messages/MOSDBoot.h"
 #include "messages/MOSDMap.h"
 #include "crimson/net/Connection.h"
@@ -38,6 +39,9 @@ OSD::OSD(int id, uint32_t nonce)
   dispatchers.push_front(this);
   dispatchers.push_front(&monc);
   osdmaps[0] = seastar::make_lw_shared<OSDMap>();
+  beacon_timer.set_callback([this] {
+    send_beacon();
+  });
 }
 
 OSD::~OSD() = default;
@@ -300,6 +304,8 @@ seastar::future<> OSD::committed_osd_maps(version_t first,
     if (state.is_booting()) {
       logger().info("osd.{}: activating...", whoami);
       state.set_active();
+      beacon_timer.arm_periodic(
+         std::chrono::seconds(local_conf()->osd_beacon_report_interval));
     }
   }
 
@@ -369,3 +375,13 @@ seastar::future<> OSD::shutdown()
   superblock.clean_thru = osdmap->get_epoch();
   return seastar::now();
 }
+
+seastar::future<> OSD::send_beacon()
+{
+  // FIXME: min lec should be calculated from pg_stat
+  //        and should set m->pgs
+  epoch_t min_last_epoch_clean = osdmap->get_epoch();
+  auto m = make_message<MOSDBeacon>(osdmap->get_epoch(),
+                                    min_last_epoch_clean);
+  return monc.send_message(m);
+}
index 13f1b2e67bac2389b8546fc64f5699d2dc1c8af7..fe6ba3d652b13d13a193d4707556a4fc3f1aaaf8 100644 (file)
@@ -4,6 +4,7 @@
 #include <seastar/core/future.hh>
 #include <seastar/core/gate.hh>
 #include <seastar/core/shared_ptr.hh>
+#include <seastar/core/timer.hh>
 
 #include "crimson/mon/MonClient.h"
 #include "crimson/net/Dispatcher.h"
@@ -22,6 +23,7 @@ namespace ceph::net {
 
 class OSD : public ceph::net::Dispatcher {
   seastar::gate gate;
+  seastar::timer<seastar::lowres_clock> beacon_timer;
   const int whoami;
   // talk with osd
   std::unique_ptr<ceph::net::Messenger> cluster_msgr;
@@ -82,4 +84,6 @@ private:
   bool should_restart() const;
   seastar::future<> restart();
   seastar::future<> shutdown();
+
+  seastar::future<> send_beacon();
 };