[Debian-ha-commits] [pacemaker] 33/69: Fix: fencing, libfencing: remap fence agent error codes before async callback

Christoph Berg myon at debian.org
Tue Jan 26 09:14:27 UTC 2016


This is an automated email from the git hooks/post-receive script.

myon pushed a commit to branch debian/master
in repository pacemaker.

commit 25326b1a3819adc0cf963f70c256ee775fa7ec5f
Author: Ken Gaillot <kgaillot at redhat.com>
Date:   Tue Jan 5 11:56:22 2016 -0600

    Fix: fencing, libfencing: remap fence agent error codes before async callback
    
    Previously, stonithd's st_child_done() remapped fence agent exit codes
    based on error output. However, since 3dd3d01, stderr is not provided
    to callbacks, so this was no longer effective. Now, the remapping is done
    in libfencing before calling the callback.
---
 fencing/commands.c      | 16 ----------------
 lib/fencing/st_client.c | 26 ++++++++++++++++++++++----
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/fencing/commands.c b/fencing/commands.c
index a81a251..e933404 100644
--- a/fencing/commands.c
+++ b/fencing/commands.c
@@ -1975,22 +1975,6 @@ st_child_done(GPid pid, int rc, const char *output, gpointer user_data)
         goto done;
     }
 
-    if (rc > 0) {
-        /* Try to provide _something_ useful */
-        if(output == NULL) {
-            rc = -ENODATA;
-
-        } else if(strstr(output, "imed out")) {
-            rc = -ETIMEDOUT;
-
-        } else if(strstr(output, "Unrecognised action")) {
-            rc = -EOPNOTSUPP;
-
-        } else {
-            rc = -pcmk_err_generic;
-        }
-    }
-
     stonith_send_async_reply(cmd, output, rc, pid);
 
     if (rc != 0) {
diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c
index a150e92..33c58b7 100644
--- a/lib/fencing/st_client.c
+++ b/lib/fencing/st_client.c
@@ -783,6 +783,9 @@ stonith_action_async_done(mainloop_child_t * p, pid_t pid, int core, int signo,
         action->timer_sigkill = 0;
     }
 
+    action->output = read_output(action->fd_stdout);
+    action->error = read_output(action->fd_stderr);
+
     if (action->last_timeout_signo) {
         action->rc = -ETIME;
         crm_notice("Child process %d performing action '%s' timed out with signal %d",
@@ -794,13 +797,28 @@ stonith_action_async_done(mainloop_child_t * p, pid_t pid, int core, int signo,
                    pid, action->action, signo);
 
     } else {
-        action->rc = exitcode;
         crm_debug("Child process %d performing action '%s' exited with rc %d",
                   pid, action->action, exitcode);
-    }
+        if (exitcode > 0) {
+            /* Try to provide a useful error code based on the fence agent's
+             * error output.
+             */
+            if (action->error == NULL) {
+                exitcode = -ENODATA;
 
-    action->output = read_output(action->fd_stdout);
-    action->error = read_output(action->fd_stderr);
+            } else if (strstr(action->error, "imed out")) {
+                /* Some agents have their own internal timeouts */
+                exitcode = -ETIMEDOUT;
+
+            } else if (strstr(action->error, "Unrecognised action")) {
+                exitcode = -EOPNOTSUPP;
+
+            } else {
+                exitcode = -pcmk_err_generic;
+            }
+        }
+        action->rc = exitcode;
+    }
 
     log_action(action, pid);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-ha/pacemaker.git



More information about the Debian-HA-Commits mailing list