// Did I previously not hold a rank? Initialize!
if (mds_rank == NULL) {
mds_rank = new MDSRankDispatcher(whoami, mds_lock, clog,
- timer, beacon, mdsmap, messenger, monc,
+ timer, beacon, mdsmap, messenger, monc, &mgrc,
new FunctionContext([this](int r){respawn();}),
new FunctionContext([this](int r){suicide();}));
dout(10) << __func__ << ": initializing MDS rank "
#include "messages/MMDSLoadTargets.h"
#include "messages/MMDSTableRequest.h"
+#include "mgr/MgrClient.h"
+
#include "MDSDaemon.h"
#include "MDSMap.h"
#include "SnapClient.h"
std::unique_ptr<MDSMap>& mdsmap_,
Messenger *msgr,
MonClient *monc_,
+ MgrClient *mgrc,
Context *respawn_hook_,
Context *suicide_hook_)
:
hb(NULL), last_tid(0), osd_epoch_barrier(0), beacon(beacon_),
mds_slow_req_count(0),
last_client_mdsmap_bcast(0),
- messenger(msgr), monc(monc_),
+ messenger(msgr), monc(monc_), mgrc(mgrc),
respawn_hook(respawn_hook_),
suicide_hook(suicide_hook_),
standby_replaying(false),
cct->_conf->mds_op_log_threshold);
op_tracker.set_history_size_and_duration(cct->_conf->mds_op_history_size,
cct->_conf->mds_op_history_duration);
+
+ std::string rank_str = stringify(get_nodeid());
+ std::map<std::string, std::string> service_metadata = {{"rank", rank_str}};
+ int r = mgrc->service_daemon_register("mds", rank_str, service_metadata);
+ if (r < 0) {
+ derr << ": failed to register with manager for service status update" << dendl;
+ }
+
+ schedule_update_timer_task();
}
MDSRank::~MDSRank()
std::unique_ptr<MDSMap> &mdsmap_,
Messenger *msgr,
MonClient *monc_,
+ MgrClient *mgrc,
Context *respawn_hook_,
Context *suicide_hook_)
: MDSRank(whoami_, mds_lock_, clog_, timer_, beacon_, mdsmap_,
- msgr, monc_, respawn_hook_, suicide_hook_)
+ msgr, monc_, mgrc, respawn_hook_, suicide_hook_)
{
g_conf().add_observer(this);
}
purge_queue.handle_conf_change(changed, *mdsmap);
}));
}
+
+void MDSRank::get_task_status(std::map<std::string, std::string> *status) {
+ dout(20) << __func__ << dendl;
+
+ // scrub summary for now..
+ std::string_view scrub_summary = scrubstack->scrub_summary();
+ status->emplace(SCRUB_STATUS_KEY, std::move(scrub_summary));
+}
+
+void MDSRank::schedule_update_timer_task() {
+ dout(20) << __func__ << dendl;
+
+ timer.add_event_after(g_conf().get_val<double>("mds_task_status_update_interval"),
+ new FunctionContext([this](int _) {
+ send_task_status();
+ }));
+}
+
+void MDSRank::send_task_status() {
+ std::map<std::string, std::string> status;
+ get_task_status(&status);
+
+ if (!status.empty()) {
+ dout(20) << __func__ << ": updating " << status.size() << " status keys" << dendl;
+
+ int r = mgrc->service_daemon_update_task_status(std::move(status));
+ if (r < 0) {
+ derr << ": failed to update service daemon status: " << cpp_strerror(r) << dendl;
+ }
+ }
+
+ schedule_update_timer_task();
+}
class Messenger;
class Objecter;
class MonClient;
+class MgrClient;
class Finisher;
class ScrubStack;
class C_MDS_Send_Command_Reply;
std::unique_ptr<MDSMap> & mdsmap_,
Messenger *msgr,
MonClient *monc_,
+ MgrClient *mgrc,
Context *respawn_hook_,
Context *suicide_hook_);
protected:
Messenger *messenger;
MonClient *monc;
+ MgrClient *mgrc;
Context *respawn_hook;
Context *suicide_hook;
private:
mono_time starttime = mono_clock::zero();
+ // "task" string that gets displayed in ceph status
+ inline static const std::string SCRUB_STATUS_KEY = "scrub status";
+
+ void get_task_status(std::map<std::string, std::string> *status);
+ void schedule_update_timer_task();
+ void send_task_status();
+
protected:
Context *create_async_exec_context(C_ExecAndReply *ctx);
};
std::unique_ptr<MDSMap> &mdsmap_,
Messenger *msgr,
MonClient *monc_,
+ MgrClient *mgrc,
Context *respawn_hook_,
Context *suicide_hook_);
};
return false;
}
+std::string_view ScrubStack::scrub_summary() {
+ ceph_assert(ceph_mutex_is_locked_by_me(mdcache->mds->mds_lock));
+
+ bool have_more = false;
+ CachedStackStringStream cs;
+
+ if (state == STATE_IDLE) {
+ return "idle";
+ }
+
+ if (state == STATE_RUNNING) {
+ if (clear_inode_stack) {
+ *cs << "aborting";
+ } else {
+ *cs << "active";
+ }
+ } else {
+ if (state == STATE_PAUSING) {
+ have_more = true;
+ *cs << "pausing";
+ } else if (state == STATE_PAUSED) {
+ have_more = true;
+ *cs << "paused";
+ }
+
+ if (clear_inode_stack) {
+ if (have_more) {
+ *cs << "+";
+ }
+ *cs << "aborting";
+ }
+ }
+
+ if (!scrub_origins.empty()) {
+ *cs << " [paths:";
+ for (auto inode = scrub_origins.begin(); inode != scrub_origins.end(); ++inode) {
+ if (inode != scrub_origins.begin()) {
+ *cs << ",";
+ }
+
+ std::string path;
+ (*inode)->make_path_string(path, true);
+ *cs << (path.empty() ? "/" : path.c_str());
+ }
+ *cs << "]";
+ }
+
+ return cs->strv();
+}
+
void ScrubStack::scrub_status(Formatter *f) {
ceph_assert(mdcache->mds->mds_lock.is_locked_by_me());