summaryrefslogtreecommitdiffstats
path: root/ctdb/tools
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2013-01-11 14:09:14 +1100
committerAmitay Isaacs <amitay@gmail.com>2013-05-24 14:08:07 +1000
commitb5ebff6931adf0564bb1cbb98a9283382c578564 (patch)
tree99743532faf52b1b502a9612309b70cddb1c9794 /ctdb/tools
parent87eb70180aad04dc353c008f48b3b5fe652fa87c (diff)
tools/ctdb: "ctdb runstate" now accepts optional expected run state arguments
If one or more run states are specified then "ctdb runstate" succeeds only if ctdbd is in one of those run states. At the moment, if the "setup" event fails then the initscript succeeds but ctdbd exits almost immediately. This behaviour isn't very friendly. The initscript now waits until ctdbd is in "startup" or "running" run state via the use of "ctdb runstate startup running", meaning that ctdbd has successfully passed the "setup" event. The "setup" event code in 00.ctdb now waits until ctdbd is in the "setup" run state before proceeding via the use of "ctdb runstate setup". Signed-off-by: Martin Schwenke <martin@meltin.net> Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 4a2effcc455be67ff4a779a59ca81ba584312cd6)
Diffstat (limited to 'ctdb/tools')
-rw-r--r--ctdb/tools/ctdb.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 842c872b64..e21e845073 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -4385,6 +4385,29 @@ static int control_runstate(struct ctdb_context *ctdb, int argc, const char **ar
printf("Unable to get runstate response from node %u\n",
options.pnn);
return -1;
+ } else {
+ bool found = true;
+ enum ctdb_runstate t;
+ int i;
+ for (i=0; i<argc; i++) {
+ found = false;
+ t = runstate_from_string(argv[i]);
+ if (t == CTDB_RUNSTATE_UNKNOWN) {
+ printf("Invalid run state (%s)\n", argv[i]);
+ return -1;
+ }
+
+ if (t == runstate) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ printf("CTDB not in required run state (got %s)\n",
+ runstate_to_string((enum ctdb_runstate)runstate));
+ return -1;
+ }
}
printf("%s\n", runstate_to_string(runstate));
@@ -5824,7 +5847,7 @@ static const struct {
{ "status", control_status, true, false, "show node status" },
{ "uptime", control_uptime, true, false, "show node uptime" },
{ "ping", control_ping, true, false, "ping all nodes" },
- { "runstate", control_runstate, true, false, "get runstate of a node" },
+ { "runstate", control_runstate, true, false, "get/check runstate of a node", "[setup|startup|running]" },
{ "getvar", control_getvar, true, false, "get a tunable variable", "<name>"},
{ "setvar", control_setvar, true, false, "set a tunable variable", "<name> <value>"},
{ "listvars", control_listvars, true, false, "list tunable variables"},