]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: move 'quorum enter|exit' and 'mon_status' to asok
authorSage Weil <sage@redhat.com>
Thu, 10 Oct 2019 23:46:17 +0000 (18:46 -0500)
committerSage Weil <sage@redhat.com>
Fri, 11 Oct 2019 14:33:51 +0000 (09:33 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MgrMonitor.cc
src/mon/MonCommands.h
src/mon/Monitor.cc
src/mon/Monitor.h

index 502a7f6cac29dff477ac134aa724b3b5e8db3235..c9cf10fc2d819d2661f16361f397bbe1c8f22844 100644 (file)
@@ -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();
 
index fee9813e46eb45965edb017acf187b1b963c652d..af63793659ec7251744855e0e7c2eda188ef581c 100644 (file)
@@ -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", \
index 1638b2b38633d43b8112e9ab2c3d348ec74d6233..534b85cad80f1e13067ca3279c3a574698af7aa0 100644 (file)
@@ -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;
index 355341b72ca607d1e0ee1fbc51430095bd1e3784..81a653edfdfbf456184bc692f945e6a46059fc18 100644 (file)
@@ -684,7 +684,7 @@ public:
                         const cmdmap_t& cmdmap,
                         const map<string,string>& 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);