From: Sage Weil Date: Thu, 10 Oct 2019 23:46:17 +0000 (-0500) Subject: mon: move 'quorum enter|exit' and 'mon_status' to asok X-Git-Tag: v15.1.0~1178^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c09b82a80a392ccd0da7677c7b424ce5cd3fa5d6;p=ceph.git mon: move 'quorum enter|exit' and 'mon_status' to asok Signed-off-by: Sage Weil --- diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index 502a7f6cac29..c9cf10fc2d81 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -640,8 +640,7 @@ void MgrMonitor::send_digests() f.flush(mdigest->health_json); f.reset(); - std::ostringstream ss; - mon->get_mon_status(&f, ss); + mon->get_mon_status(&f); f.flush(mdigest->mon_status_json); f.reset(); diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index fee9813e46eb..af63793659ec 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -242,8 +242,6 @@ COMMAND("mon ok-to-rm " \ "check whether removing the specified mon would break quorum", "mon", "r") -COMMAND_WITH_FLAG("mon_status", "report status of monitors", "mon", "r", - FLAG(NOFORWARD)) COMMAND_WITH_FLAG("sync force " \ "name=yes_i_really_mean_it,type=CephBool,req=false " \ "name=i_know_what_i_am_doing,type=CephBool,req=false", \ @@ -254,8 +252,6 @@ COMMAND_WITH_FLAG("heap " \ "name=heapcmd,type=CephChoices,strings=dump|start_profiler|stop_profiler|release|stats", \ "show heap usage info (available only if compiled with tcmalloc)", \ "mon", "rw", FLAG(NOFORWARD)) -COMMAND("quorum name=quorumcmd,type=CephChoices,strings=enter|exit,n=1", \ - "enter or exit quorum", "mon", "rw") COMMAND("tell " \ "name=target,type=CephName " \ "name=args,type=CephString,n=N", \ diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 1638b2b38633..534b85cad80f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -308,7 +308,7 @@ void Monitor::do_admin_command( << "cmd='" << command << "' args=" << args << ": dispatch"; if (command == "mon_status") { - get_mon_status(f, out); + get_mon_status(f); } else if (command == "quorum_status") { _quorum_status(f, out); } else if (command == "sync_force") { @@ -356,6 +356,20 @@ void Monitor::do_admin_command( err << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \ please enable \"mon_enable_op_tracker\", and the tracker will start to track new ops received afterwards."; } + } else if (command == "quorum") { + string quorumcmd; + cmd_getval(g_ceph_context, cmdmap, "quorumcmd", quorumcmd); + if (quorumcmd == "exit") { + start_election(); + elector.stop_participating(); + out << "stopped responding to quorum, initiated new election" << std::endl; + } else if (quorumcmd == "enter") { + elector.start_participating(); + start_election(); + out << "started responding to quorum, initiated new election" << std::endl; + } else { + err << "needs a valid 'quorum' command" << std::endl; + } } else if (command == "smart") { string want_devid; cmd_getval(cct, cmdmap, "devid", want_devid); @@ -2537,16 +2551,8 @@ void Monitor::_quorum_status(Formatter *f, ostream& ss) delete f; } -void Monitor::get_mon_status(Formatter *f, ostream& ss) +void Monitor::get_mon_status(Formatter *f) { - bool free_formatter = false; - - if (!f) { - // louzy/lazy hack: default to json if no formatter has been defined - f = new JSONFormatter(); - free_formatter = true; - } - f->open_object_section("mon_status"); f->dump_string("name", name); f->dump_int("rank", rank); @@ -2618,12 +2624,6 @@ void Monitor::get_mon_status(Formatter *f, ostream& ss) f->dump_object("feature_map", session_map.feature_map); f->close_section(); // mon_status - - if (free_formatter) { - // flush formatter to ss and delete it iff we created the formatter - f->flush(ss); - delete f; - } } @@ -3742,13 +3742,6 @@ void Monitor::handle_command(MonOpRequestRef op) } r = 0; rs = "safe to remove mon." + id; - } else if (prefix == "mon_status") { - get_mon_status(f.get(), ds); - if (f) - f->flush(ds); - rdata.append(ds); - rs = ""; - r = 0; } else if (prefix == "sync force" || prefix == "mon sync force") { bool validate1 = false; @@ -3783,23 +3776,6 @@ void Monitor::handle_command(MonOpRequestRef op) rs = ""; r = 0; } - } else if (prefix == "quorum") { - string quorumcmd; - cmd_getval(g_ceph_context, cmdmap, "quorumcmd", quorumcmd); - if (quorumcmd == "exit") { - start_election(); - elector.stop_participating(); - rs = "stopped responding to quorum, initiated new election"; - r = 0; - } else if (quorumcmd == "enter") { - elector.start_participating(); - start_election(); - rs = "started responding to quorum, initiated new election"; - r = 0; - } else { - rs = "needs a valid 'quorum' command"; - r = -EINVAL; - } } else if (prefix == "version") { if (f) { f->open_object_section("version"); @@ -4618,10 +4594,7 @@ void Monitor::handle_ping(MonOpRequestRef op) f->open_object_section("pong"); healthmon()->get_health_status(false, f.get(), nullptr); - { - stringstream ss; - get_mon_status(f.get(), ss); - } + get_mon_status(f.get()); f->close_section(); stringstream ss; diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 355341b72ca6..81a653edfdfb 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -684,7 +684,7 @@ public: const cmdmap_t& cmdmap, const map& param_str_map, const MonCommand *this_cmd); - void get_mon_status(Formatter *f, ostream& ss); + void get_mon_status(Formatter *f); void _quorum_status(Formatter *f, ostream& ss); bool _add_bootstrap_peer_hint(std::string_view cmd, const cmdmap_t& cmdmap, std::ostream& ss);