From a36a7cf7f97cf0bf227e81294fb43743475734a5 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 20 Jul 2015 16:37:58 +1000 Subject: [PATCH 1/3] ctdb-tool: Correctly print timed out event scripts output The timed out error is ignored for certain events (start_recovery, recoverd, takeip, releaseip). If these events time out, then the debug hung script outputs the following: 3 scripts were executed last releaseip cycle 00.ctdb Status:OK Duration:4.381 Thu Jul 16 23:45:24 2015 01.reclock Status:OK Duration:13.422 Thu Jul 16 23:45:28 2015 10.external Status:DISABLED 10.interface Status:OK Duration:-1437083142.208 Thu Jul 16 23:45:42 2015 The endtime for timed out scripts is not set. Since the status is not returned as -ETIME for some events, ctdb scriptstatus prints -ve duration. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11431 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit 71b89b2b7a9768de437347e6678370b2682da892) --- ctdb/tools/ctdb.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 4734b26..c6da621 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -1424,6 +1424,14 @@ static int control_one_scriptstatus(struct ctdb_context *ctdb, for (i=0; inum_scripts; i++) { const char *status = NULL; + /* The ETIME status is ignored for certain events. + * In that case the status is 0, but endtime is not set. + */ + if (script_status->scripts[i].status == 0 && + timeval_is_zero(&script_status->scripts[i].finished)) { + script_status->scripts[i].status = -ETIME; + } + switch (script_status->scripts[i].status) { case -ETIME: status = "TIMEDOUT"; -- 2.4.6 From fac25c6da58cc89a1c699c35ec408ac86779b426 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 21 Jul 2015 16:37:04 +1000 Subject: [PATCH 2/3] ctdb-daemon: Correctly process the exit code from failed eventscripts BUG: https://bugzilla.samba.org/show_bug.cgi?id=11431 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Wed Jul 22 15:03:53 CEST 2015 on sn-devel-104 (cherry picked from commit 00ec3c477eba50206801b451ae4eb64c12aba5db) --- ctdb/server/ctdb_event_helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ctdb/server/ctdb_event_helper.c b/ctdb/server/ctdb_event_helper.c index f14e336..a1b5318 100644 --- a/ctdb/server/ctdb_event_helper.c +++ b/ctdb/server/ctdb_event_helper.c @@ -128,7 +128,11 @@ int main(int argc, char *argv[]) exit(1); } if (WIFEXITED(status)) { - output = -WEXITSTATUS(status); + output = WEXITSTATUS(status); + /* Only errors should be returned as -ve values */ + if (output == ENOENT || output == ENOEXEC) { + output = -output; + } sys_write(write_fd, &output, sizeof(output)); exit(0); } -- 2.4.6 From 0ce5a8147c1c0d63f4d455c4dd9ea40ec249079b Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 24 Jul 2015 07:39:26 +1000 Subject: [PATCH 3/3] ctdb-client: Return the correct status sent from the daemon If a control fails and error message is set, the returned status of the control is always set to -1 ignoring the status passed by the daemon. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11431 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit 1286b02e24a521dafa7061d09fb5c21d1ebb3011) --- ctdb/client/ctdb_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index 7bffefe..3383c57 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -1138,7 +1138,7 @@ int ctdb_control_recv(struct ctdb_context *ctdb, state->async.fn(state); } talloc_free(tmp_ctx); - return -1; + return (status == 0 ? -1 : state->status); } if (outdata) { -- 2.4.6