]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Monitor: make 'quorum enter/exit' available through the admin socket
authorJoao Eduardo Luis <joao.luis@inktank.com>
Fri, 8 Nov 2013 00:26:42 +0000 (00:26 +0000)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Fri, 8 Nov 2013 00:26:42 +0000 (00:26 +0000)
If we don't have at least 'quorum enter' available through the admin
socket, then we can never tell a monitor to go back into quorum after
exiting, since it will not handle the command that forces it back in due
to not being in the quorum.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/Monitor.cc

index cd541f6bf836062d91073ee3b5c1b965a8038aa3..b35269baf15df7bfaf8ed35af84227a91719080e 100644 (file)
@@ -258,9 +258,17 @@ void Monitor::do_admin_command(string command, cmdmap_t& cmdmap, string format,
       return;
     }
     sync_force(f.get(), ss);
-  } else if (command.find("add_bootstrap_peer_hint") == 0)
+  } else if (command.find("add_bootstrap_peer_hint") == 0) {
     _add_bootstrap_peer_hint(command, cmdmap, ss);
-  else
+  } else if (command == "quorum enter") {
+    elector.start_participating();
+    start_election();
+    ss << "started responding to quorum, initiated new election";
+  } else if (command == "quorum exit") {
+    start_election();
+    elector.stop_participating();
+    ss << "stopped responding to quorum, initiated new election";
+  } else
     assert(0 == "bad AdminSocket command binding");
 }
 
@@ -504,6 +512,14 @@ int Monitor::preinit()
                                     "add peer address as potential bootstrap"
                                     " peer for cluster bringup");
   assert(r == 0);
+  r = admin_socket->register_command("quorum enter", "quorum enter",
+                                     admin_hook,
+                                     "force monitor back into quorum");
+  assert(r == 0);
+  r = admin_socket->register_command("quorum exit", "quorum exit",
+                                     admin_hook,
+                                     "force monitor out of the quorum");
+  assert(r == 0);
   lock.Lock();
 
   lock.Unlock();