]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add osdmonitor_prepare_command to the admin socket
authorLoic Dachary <loic@dachary.org>
Wed, 12 Feb 2014 15:49:32 +0000 (16:49 +0100)
committerLoic Dachary <loic@dachary.org>
Thu, 13 Feb 2014 08:52:23 +0000 (09:52 +0100)
It provides a developer path allowing functional tests to modify the
pending OSDMap without triggering a PaxosProposal.

It can be used as follows:

   echo '{"prefix":"osdmonitor_prepare_command","prepare":"osd crush tunables","profile":"bobtail"}' | nc -U out/mon.a.asok

It will transform the command into:

  {"prefix":"osd crush tunables","profile":"bobtail"}

and feed it to OSDMonitor::prepare_command_impl(). The pending OSDMap won't
be proposed because it short circuit PaxosService::dispatch. It will,
however, be proposed next time PaxosService::dispatch() gets a chance.

It cannot be used via the ceph command line.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/mon/Monitor.cc
src/mon/Monitor.h

index a59dcbe211652ecf92abad91f84817ff3bd08c4f..8639cc70439b6e07e318400ceddd74e9670bd047 100644 (file)
@@ -277,6 +277,8 @@ void Monitor::do_admin_command(string command, cmdmap_t& cmdmap, string format,
     sync_force(f.get(), ss);
   } else if (command.find("add_bootstrap_peer_hint") == 0) {
     _add_bootstrap_peer_hint(command, cmdmap, ss);
+  } else if (command.find("osdmonitor_prepare_command") == 0) {
+    _osdmonitor_prepare_command(cmdmap, ss);
   } else if (command == "quorum enter") {
     elector.start_participating();
     start_election();
@@ -518,6 +520,11 @@ int Monitor::preinit()
   r = admin_socket->register_command("mon_status", "mon_status", admin_hook,
                                     "show current monitor status");
   assert(r == 0);
+  if (g_conf->mon_advanced_debug_mode) {
+    r = admin_socket->register_command("osdmonitor_prepare_command", "osdmonitor_prepare_command", admin_hook,
+                                      "call OSDMonitor::prepare_command");
+    assert(r == 0);
+  }
   r = admin_socket->register_command("quorum_status", "quorum_status",
                                     admin_hook, "show current quorum status");
   assert(r == 0);
@@ -746,6 +753,26 @@ void Monitor::bootstrap()
   }
 }
 
+void Monitor::_osdmonitor_prepare_command(cmdmap_t& cmdmap, ostream& ss)
+{
+  if (!is_leader()) {
+    ss << "mon must be a leader";
+    return;
+  }
+
+  string cmd;
+  cmd_getval(g_ceph_context, cmdmap, "prepare", cmd);
+  cmdmap["prefix"] = cmdmap["prepare"];
+  
+  OSDMonitor *monitor = osdmon();
+  MMonCommand *m = static_cast<MMonCommand *>((new MMonCommand())->get());
+  if (monitor->prepare_command_impl(m, cmdmap))
+    ss << "true";
+  else
+    ss << "false";
+  m->put();
+}
+
 void Monitor::_add_bootstrap_peer_hint(string cmd, cmdmap_t& cmdmap, ostream& ss)
 {
   string addrstr;
index 47fa6587aa32aaa4e575428fea0f1988167c8924..d7a165f88793898a1bd19a62cae8730ecd6fac09 100644 (file)
@@ -620,6 +620,7 @@ public:
                         const MonCommand *this_cmd);
   void _mon_status(Formatter *f, ostream& ss);
   void _quorum_status(Formatter *f, ostream& ss);
+  void _osdmonitor_prepare_command(cmdmap_t& cmdmap, ostream& ss);
   void _add_bootstrap_peer_hint(string cmd, cmdmap_t& cmdmap, ostream& ss);
   void handle_command(class MMonCommand *m);
   void handle_route(MRoute *m);