daemon: Improve error messages when eventscript control is cancelled
authorMartin Schwenke <martin@meltin.net>
Mon, 6 Jul 2015 02:02:00 +0000 (12:02 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 16 Jul 2015 04:37:12 +0000 (14:37 +1000)
Warn specifically about cancellation instead of printing a generic
error message.  Also pass back an error message for the tool - it
could just rely on the status but it already looks at the error
message.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 122a4fda7272ec4d63452037f0b838d2bdc5a79a)

server/eventscript.c

index 34e7d41343b698e7518e96aea422482c4c46c32f..77f2cd5705ef98dbee5ec7e7521033ffd9ff85d8 100644 (file)
@@ -905,14 +905,23 @@ struct eventscript_callback_state {
 static void run_eventscripts_callback(struct ctdb_context *ctdb, int status, 
                                 void *private_data)
 {
+       const char *errmsg = NULL;
+
        struct eventscript_callback_state *state = 
                talloc_get_type(private_data, struct eventscript_callback_state);
 
        if (status != 0) {
-               DEBUG(DEBUG_ERR,(__location__ " Failed to run eventscripts\n"));
+               if (status == -ECANCELED) {
+                       DEBUG(DEBUG_WARNING,
+                             (__location__ " Eventscript cancelled\n"));
+                       errmsg = "cancelled";
+               } else {
+                       DEBUG(DEBUG_ERR,
+                             (__location__ " Failed to run eventscripts\n"));
+               }
        }
 
-       ctdb_request_control_reply(ctdb, state->c, NULL, status, NULL);
+       ctdb_request_control_reply(ctdb, state->c, NULL, status, errmsg);
        /* This will free the struct ctdb_event_script_state we are in! */
        talloc_free(state);
        return;