From: Kefu Chai Date: Mon, 14 Jan 2019 09:48:18 +0000 (+0800) Subject: crimson/osd: send beacon to mon periodically X-Git-Tag: v14.1.0~356^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=33928e0a38358ac7fad4f052dfedab5894c765b3;p=ceph.git crimson/osd: send beacon to mon periodically so monitor won't mark crimson-osd down and out Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index afde4ef1dde..e51182eeccc 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -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(); + 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(osdmap->get_epoch(), + min_last_epoch_clean); + return monc.send_message(m); +} diff --git a/src/crimson/osd/osd.h b/src/crimson/osd/osd.h index 13f1b2e67ba..fe6ba3d652b 100644 --- a/src/crimson/osd/osd.h +++ b/src/crimson/osd/osd.h @@ -4,6 +4,7 @@ #include #include #include +#include #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 beacon_timer; const int whoami; // talk with osd std::unique_ptr cluster_msgr; @@ -82,4 +84,6 @@ private: bool should_restart() const; seastar::future<> restart(); seastar::future<> shutdown(); + + seastar::future<> send_beacon(); };