From b5ebff6931adf0564bb1cbb98a9283382c578564 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 11 Jan 2013 14:09:14 +1100 Subject: 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 Pair-programmed-with: Amitay Isaacs (This used to be ctdb commit 4a2effcc455be67ff4a779a59ca81ba584312cd6) --- ctdb/config/ctdb.init | 2 +- ctdb/config/events.d/00.ctdb | 2 +- ctdb/doc/ctdb.1.xml | 7 ++++++- ctdb/tools/ctdb.c | 25 ++++++++++++++++++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ctdb/config/ctdb.init b/ctdb/config/ctdb.init index 6c4e16d0de..70dcfa6421 100755 --- a/ctdb/config/ctdb.init +++ b/ctdb/config/ctdb.init @@ -220,7 +220,7 @@ wait_until_ready () { _timeout="${1:-10}" # default is 10 seconds _count=0 - while ! ctdb ping >/dev/null 2>&1 ; do + while ! ctdb runstate startup running >/dev/null 2>&1 ; do if [ $_count -ge $_timeout ] ; then return 1 fi diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb index c1ac11a923..02d1569107 100755 --- a/ctdb/config/events.d/00.ctdb +++ b/ctdb/config/events.d/00.ctdb @@ -53,7 +53,7 @@ wait_until_ready () { _timeout="${1:-10}" # default is 10 seconds _count=0 - while ! ctdb ping >/dev/null 2>&1 ; do + while ! ctdb runstate setup >/dev/null 2>&1 ; do if [ $_count -ge $_timeout ] ; then return 1 fi diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml index d1734b7c8f..7242f3aa29 100644 --- a/ctdb/doc/ctdb.1.xml +++ b/ctdb/doc/ctdb.1.xml @@ -382,12 +382,17 @@ response from 3 time=0.000114 sec (2 clients) - runstate + runstate [setup|startup|running] Print the runstate of the specified node. Runstates are used to serialise important state transitions in CTDB, particularly during startup. + + If one or more optional runstate arguments are specified then + the node must be in one of these runstates for the command to + succeed. + Example: ctdb runstate 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"}, { "setvar", control_setvar, true, false, "set a tunable variable", " "}, { "listvars", control_listvars, true, false, "list tunable variables"}, -- cgit