From c73eeb58bbd29f901fe447fd083091533f27967f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 30 May 2017 16:37:22 -0400 Subject: [PATCH] mon: add 'features' command to show connected client features for whole mon cluster Signed-off-by: Sage Weil --- src/mon/MonCommands.h | 2 ++ src/mon/Monitor.cc | 28 ++++++++++++++++++++++++++++ src/mon/Monitor.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 610564ff11de5..d42b59d7e9590 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -206,6 +206,8 @@ COMMAND("df name=detail,type=CephChoices,strings=detail,req=false", \ COMMAND("report name=tags,type=CephString,n=N,req=false", \ "report full status of cluster, optional title tag strings", \ "mon", "r", "cli,rest") +COMMAND("features", "report of connected features", \ + "mon", "r", "cli,rest") COMMAND("quorum_status", "report status of monitor quorum", \ "mon", "r", "cli,rest") diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 061f0d69b2d6e..03346133a7f94 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2112,6 +2112,16 @@ void Monitor::calc_quorum_requirements() dout(10) << __func__ << " required_features " << required_features << dendl; } +void Monitor::get_combined_feature_map(FeatureMap *fm) +{ + *fm += session_map.feature_map; + for (auto id : quorum) { + if (id != rank) { + *fm += quorum_feature_map[id]; + } + } +} + void Monitor::sync_force(Formatter *f, ostream& ss) { bool free_formatter = false; @@ -3145,6 +3155,24 @@ void Monitor::handle_command(MonOpRequestRef op) rdata.append(ds); rs = ""; r = 0; + } else if (prefix == "features") { + if (!is_leader() && !is_peon()) { + dout(10) << " waiting for quorum" << dendl; + waitfor_quorum.push_back(new C_RetryMessage(this, op)); + return; + } + if (!is_leader()) { + forward_request_leader(op); + return; + } + if (!f) + f.reset(Formatter::create("json-pretty")); + FeatureMap fm; + get_combined_feature_map(&fm); + f->dump_object("features", fm); + f->flush(rdata); + rs = ""; + r = 0; } else if (prefix == "mon metadata") { if (!f) f.reset(Formatter::create("json-pretty")); diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 39b23517a1fab..e0e93140d3e42 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -576,6 +576,8 @@ public: void apply_monmap_to_compatset_features(); void calc_quorum_requirements(); + void get_combined_feature_map(FeatureMap *fm); + private: void _reset(); ///< called from bootstrap, start_, or join_election void wait_for_paxos_write(); -- 2.39.5