The Samba-Bugzilla – Attachment 11307 Details for
Bug 11431
CTDB's eventscript error handling is broken
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patches for 4.2
v4-2-test-BZ11431.patch (text/plain), 7.80 KB, created by
Martin Schwenke
on 2015-08-05 06:45:01 UTC
(
hide
)
Description:
Patches for 4.2
Filename:
MIME Type:
Creator:
Martin Schwenke
Created:
2015-08-05 06:45:01 UTC
Size:
7.80 KB
patch
obsolete
>From ead491c25a3825f3729bb3ec8d290e3ad97809b2 Mon Sep 17 00:00:00 2001 >From: Amitay Isaacs <amitay@gmail.com> >Date: Mon, 20 Jul 2015 16:37:58 +1000 >Subject: [PATCH 1/4] 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 <amitay@gmail.com> >Reviewed-by: Martin Schwenke <martin@meltin.net> >(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 c386d35..6911dff 100644 >--- a/ctdb/tools/ctdb.c >+++ b/ctdb/tools/ctdb.c >@@ -1453,6 +1453,14 @@ static int control_one_scriptstatus(struct ctdb_context *ctdb, > for (i=0; i<script_status->num_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 c83f44a8cfb36c0154cf99785e714ad715a30edb Mon Sep 17 00:00:00 2001 >From: Amitay Isaacs <amitay@gmail.com> >Date: Thu, 13 Nov 2014 11:02:26 +1100 >Subject: [PATCH 2/4] ctdb-daemon: Improve error handling for running event > scripts > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11431 > >Signed-off-by: Amitay Isaacs <amitay@gmail.com> >Reviewed-by: Martin Schwenke <martin@meltin.net> > >Autobuild-User(master): Martin Schwenke <martins@samba.org> >Autobuild-Date(master): Fri Nov 14 03:06:12 CET 2014 on sn-devel-104 > >(cherry picked from commit d04bfc6ec6ad7a4749ebfee2284253c4a91a81aa) >--- > ctdb/server/ctdb_event_helper.c | 48 ++++++++++++++++++++++++++--------------- > ctdb/server/eventscript.c | 10 +++++++-- > 2 files changed, 39 insertions(+), 19 deletions(-) > >diff --git a/ctdb/server/ctdb_event_helper.c b/ctdb/server/ctdb_event_helper.c >index 9ff763c..f14e336 100644 >--- a/ctdb/server/ctdb_event_helper.c >+++ b/ctdb/server/ctdb_event_helper.c >@@ -67,7 +67,7 @@ int main(int argc, char *argv[]) > { > int log_fd, write_fd; > pid_t pid; >- int status, output; >+ int status, output, ret; > > progname = argv[0]; > >@@ -99,33 +99,47 @@ int main(int argc, char *argv[]) > > pid = fork(); > if (pid < 0) { >+ int save_errno = errno; > fprintf(stderr, "Failed to fork - %s\n", strerror(errno)); >- exit(errno); >+ sys_write(write_fd, &save_errno, sizeof(save_errno)); >+ exit(1); > } > > if (pid == 0) { >- int save_errno; >- >- execv(argv[3], &argv[3]); >- if (errno == EACCES) { >- save_errno = check_executable(argv[3]); >- } else { >- save_errno = errno; >+ ret = check_executable(argv[3]); >+ if (ret != 0) { >+ _exit(ret); >+ } >+ ret = execv(argv[3], &argv[3]); >+ if (ret != 0) { >+ int save_errno = errno; > fprintf(stderr, "Error executing '%s' - %s\n", >- argv[3], strerror(errno)); >+ argv[3], strerror(save_errno)); > } >- _exit(save_errno); >+ /* This should never happen */ >+ _exit(ENOEXEC); > } > >- waitpid(pid, &status, 0); >+ ret = waitpid(pid, &status, 0); >+ if (ret == -1) { >+ output = -errno; >+ fprintf(stderr, "waitpid() failed - %s\n", strerror(errno)); >+ sys_write(write_fd, &output, sizeof(output)); >+ exit(1); >+ } > if (WIFEXITED(status)) { >- output = WEXITSTATUS(status); >- if (output == ENOENT || output == ENOEXEC) { >- output = -output; >- } >+ output = -WEXITSTATUS(status); >+ sys_write(write_fd, &output, sizeof(output)); >+ exit(0); >+ } >+ if (WIFSIGNALED(status)) { >+ output = -EINTR; >+ fprintf(stderr, "Process terminated with signal - %d\n", >+ WTERMSIG(status)); > sys_write(write_fd, &output, sizeof(output)); >- exit(output); >+ exit(0); > } > >+ fprintf(stderr, "waitpid() status=%d\n", status); > exit(1); > } >diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c >index e3131b3..1f16580 100644 >--- a/ctdb/server/eventscript.c >+++ b/ctdb/server/eventscript.c >@@ -379,6 +379,8 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event > r = sys_read(state->fd[0], ¤t->status, sizeof(current->status)); > if (r < 0) { > current->status = -errno; >+ } else if (r == 0) { >+ current->status = -EINTR; > } else if (r != sizeof(current->status)) { > current->status = -EIO; > } >@@ -396,8 +398,12 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event > > /* Aborted or finished all scripts? We're done. */ > if (status != 0 || state->current+1 == state->scripts->num_scripts) { >- DEBUG(DEBUG_INFO,(__location__ " Eventscript %s %s finished with state %d\n", >- ctdb_eventscript_call_names[state->call], state->options, status)); >+ if (status != 0) { >+ DEBUG(DEBUG_INFO, >+ ("Eventscript %s %s finished with state %d\n", >+ ctdb_eventscript_call_names[state->call], >+ state->options, status)); >+ } > > ctdb->event_script_timeouts = 0; > talloc_free(state); >-- >2.4.6 > > >From b0a13d44679581bb871b65718627e0376f2cdd5b Mon Sep 17 00:00:00 2001 >From: Amitay Isaacs <amitay@gmail.com> >Date: Tue, 21 Jul 2015 16:37:04 +1000 >Subject: [PATCH 3/4] 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 <amitay@gmail.com> >Reviewed-by: Martin Schwenke <martin@meltin.net> > >Autobuild-User(master): Martin Schwenke <martins@samba.org> >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 abcef3d4c760b345c30d3542b167c959f0a94ac4 Mon Sep 17 00:00:00 2001 >From: Amitay Isaacs <amitay@gmail.com> >Date: Fri, 24 Jul 2015 07:39:26 +1000 >Subject: [PATCH 4/4] 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 <amitay@gmail.com> >Reviewed-by: Martin Schwenke <martin@meltin.net> >(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 da18826..c9c38f7 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 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
amitay
:
review+
Actions:
View
Attachments on
bug 11431
:
11307
|
11308
|
11329
|
11330