ctdb-daemon: No need to call event scripts with CTDB_CALLED_BY_USER
authorAmitay Isaacs <amitay@gmail.com>
Mon, 16 Dec 2013 04:57:42 +0000 (15:57 +1100)
committerMartin Schwenke <martin@meltin.net>
Thu, 16 Jan 2014 00:41:12 +0000 (11:41 +1100)
This was added to support external monitoring using CTDB event scripts.
However, it was never used.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/include/ctdb_private.h
ctdb/server/ctdb_daemon.c
ctdb/server/ctdb_monitor.c
ctdb/server/ctdb_recover.c
ctdb/server/ctdb_takeover.c
ctdb/server/eventscript.c

index 71c9f139b1f1fba6c778c2c73e09c1287b634b14..c099a02247c9e92289f6eb8e84f37cc6c82a76c4 100644 (file)
@@ -1245,9 +1245,8 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb,
                               TALLOC_CTX *mem_ctx,
                               void (*callback)(struct ctdb_context *, int, void *),
                               void *private_data,
-                              bool from_user,
                               enum ctdb_eventscript_call call,
-                              const char *fmt, ...) PRINTF_ATTRIBUTE(7,8);
+                              const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
 void ctdb_release_all_ips(struct ctdb_context *ctdb);
 
 void set_nonblocking(int fd);
index 50b2de327ecfb00d8c29257215fbfac3e0e6f799..aa0cedbcd8ce6ca8d87cba0e1cdafd684ed78705 100644 (file)
@@ -1312,7 +1312,6 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
                                         ctdb,
                                         ctdb_setup_event_callback,
                                         ctdb,
-                                        false,
                                         CTDB_EVENT_SETUP,
                                         "%s",
                                         "");
index acd68c834daf5751eec5040292286ac88e6f33bd..2b52fd0758c57895474c9c2b4b056b1f0767cc7e 100644 (file)
@@ -337,7 +337,7 @@ static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
                DEBUG(DEBUG_NOTICE,("Recoveries finished. Running the \"startup\" event.\n"));
                ret = ctdb_event_script_callback(ctdb, 
                                                 ctdb->monitor->monitor_context, ctdb_startup_callback, 
-                                                ctdb, false,
+                                                ctdb,
                                                 CTDB_EVENT_STARTUP, "%s", "");
        } else {
                int i;
@@ -362,7 +362,7 @@ static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
                } else {
                        ret = ctdb_event_script_callback(ctdb, 
                                        ctdb->monitor->monitor_context, ctdb_health_callback,
-                                       ctdb, false,
+                                       ctdb,
                                        CTDB_EVENT_MONITOR, "%s", "");
                }
        }
index 414f5b1f8d948b603cca38cc6f330162f45b56c9..7249f50ff4cdaf42eb6847e4f8554ee9765a9220 100644 (file)
@@ -944,7 +944,6 @@ int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb,
        ret = ctdb_event_script_callback(ctdb, state,
                                         ctdb_end_recovery_callback, 
                                         state, 
-                                        false,
                                         CTDB_EVENT_RECOVERED, "%s", "");
 
        if (ret != 0) {
@@ -998,7 +997,7 @@ int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
 
        ret = ctdb_event_script_callback(ctdb, state,
                                         ctdb_start_recovery_callback, 
-                                        state, false,
+                                        state,
                                         CTDB_EVENT_START_RECOVERY,
                                         "%s", "");
 
index 04cdd6668d3a3fe7f19d5c250ad313e699606ed5..0d859f9d851e7dbace884c61d651fab63375b1f9 100644 (file)
@@ -510,7 +510,6 @@ static int32_t ctdb_do_takeip(struct ctdb_context *ctdb,
                                         state,
                                         ctdb_do_takeip_callback,
                                         state,
-                                        false,
                                         CTDB_EVENT_TAKE_IP,
                                         "%s %s %u",
                                         ctdb_vnn_iface_string(vnn),
@@ -651,7 +650,6 @@ static int32_t ctdb_do_updateip(struct ctdb_context *ctdb,
                                         state,
                                         ctdb_do_updateip_callback,
                                         state,
-                                        false,
                                         CTDB_EVENT_UPDATE_IP,
                                         "%s %s %s %u",
                                         state->old->name,
@@ -1024,7 +1022,6 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
 
        ret = ctdb_event_script_callback(ctdb, 
                                         state, release_ip_callback, state,
-                                        false,
                                         CTDB_EVENT_RELEASE_IP,
                                         "%s %s %u",
                                         iface,
@@ -4192,7 +4189,6 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA inda
 
                        ret = ctdb_event_script_callback(ctdb, 
                                         mem_ctx, delete_ip_callback, mem_ctx,
-                                        false,
                                         CTDB_EVENT_RELEASE_IP,
                                         "%s %s %u",
                                         ctdb_vnn_iface_string(vnn),
@@ -4250,7 +4246,7 @@ int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb,
 
        ret = ctdb_event_script_callback(ctdb, state,
                                         ctdb_ipreallocated_callback, state,
-                                        false, CTDB_EVENT_IPREALLOCATED,
+                                        CTDB_EVENT_IPREALLOCATED,
                                         "%s", "");
 
        if (ret != 0) {
index 4e61941a6ee112aaa8c20aefd2c8614774c1d52f..61406010221b4ecd2e02d9d4e7b854e590ae561c 100644 (file)
@@ -62,7 +62,6 @@ struct ctdb_event_script_state {
        struct event_script_callback *callback;
        pid_t child;
        int fd[2];
-       bool from_user;
        enum ctdb_eventscript_call call;
        const char *options;
        struct timeval timeout;
@@ -282,33 +281,15 @@ static int child_setup(struct ctdb_context *ctdb)
 
 static char *child_command_string(struct ctdb_context *ctdb,
                                       TALLOC_CTX *ctx,
-                                      bool from_user,
                                       const char *scriptname,
                                       enum ctdb_eventscript_call call,
                                       const char *options)
 {
-       const char *str = from_user ? "CTDB_CALLED_BY_USER=1 " : "";
-
-       /* Allow a setting where we run the actual monitor event
-          from an external source and replace it with
-          a "status" event that just picks up the actual
-          status of the event asynchronously.
-       */
-       if ((ctdb->tunable.use_status_events_for_monitoring != 0)
-           &&  (call == CTDB_EVENT_MONITOR)
-           &&  !from_user) {
-               return talloc_asprintf(ctx, "%s%s/%s %s",
-                                      str,
-                                      ctdb->event_script_dir,
-                                      scriptname, "status");
-       } else {
-               return talloc_asprintf(ctx, "%s%s/%s %s %s",
-                                      str,
-                                      ctdb->event_script_dir,
-                                      scriptname,
-                                      ctdb_eventscript_call_names[call],
-                                      options);
-       }
+       return talloc_asprintf(ctx, "%s/%s %s %s",
+                              ctdb->event_script_dir,
+                              scriptname,
+                              ctdb_eventscript_call_names[call],
+                              options);
 }
 
 static int child_run_one(struct ctdb_context *ctdb,
@@ -344,7 +325,6 @@ static int child_run_one(struct ctdb_context *ctdb,
   which allows it to do blocking calls such as system()
  */
 static int child_run_script(struct ctdb_context *ctdb,
-                           bool from_user,
                            enum ctdb_eventscript_call call,
                            const char *options,
                            struct ctdb_script_wire *current)
@@ -357,7 +337,7 @@ static int child_run_script(struct ctdb_context *ctdb,
        if (ret != 0)
                goto out;
 
-       cmdstr = child_command_string(ctdb, tmp_ctx, from_user,
+       cmdstr = child_command_string(ctdb, tmp_ctx,
                                      current->name, call, options);
        CTDB_NO_MEMORY(ctdb, cmdstr);
 
@@ -411,7 +391,7 @@ static int fork_child_for_script(struct ctdb_context *ctdb,
                set_close_on_exec(state->fd[1]);
                ctdb_set_process_name("ctdb_eventscript");
 
-               rt = child_run_script(ctdb, state->from_user, state->call, state->options, current);
+               rt = child_run_script(ctdb, state->call, state->options, current);
                /* We must be able to write PIPEBUF bytes at least; if this
                   somehow fails, the read above will be short. */
                write(state->fd[1], &rt, sizeof(rt));
@@ -775,7 +755,6 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
                                        const void *mem_ctx,
                                        void (*callback)(struct ctdb_context *, int, void *),
                                        void *private_data,
-                                       bool from_user,
                                        enum ctdb_eventscript_call call,
                                        const char *fmt, va_list ap)
 {
@@ -834,7 +813,6 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
        state->callback->private_data = private_data;
 
        state->ctdb = ctdb;
-       state->from_user = from_user;
        state->call = call;
        state->options = talloc_vasprintf(state, fmt, ap);
        state->timeout = timeval_set(ctdb->tunable.script_timeout, 0);
@@ -864,7 +842,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
        state->current = 0;
        state->child = 0;
 
-       if (!from_user && (call == CTDB_EVENT_MONITOR)) {
+       if (call == CTDB_EVENT_MONITOR) {
                ctdb->current_monitor = state;
        }
 
@@ -903,7 +881,6 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb,
                               TALLOC_CTX *mem_ctx,
                               void (*callback)(struct ctdb_context *, int, void *),
                               void *private_data,
-                              bool from_user,
                               enum ctdb_eventscript_call call,
                               const char *fmt, ...)
 {
@@ -911,7 +888,7 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb,
        int ret;
 
        va_start(ap, fmt);
-       ret = ctdb_event_script_callback_v(ctdb, mem_ctx, callback, private_data, from_user, call, fmt, ap);
+       ret = ctdb_event_script_callback_v(ctdb, mem_ctx, callback, private_data, call, fmt, ap);
        va_end(ap);
 
        return ret;
@@ -946,7 +923,7 @@ int ctdb_event_script_args(struct ctdb_context *ctdb, enum ctdb_eventscript_call
 
        va_start(ap, fmt);
        ret = ctdb_event_script_callback_v(ctdb, ctdb,
-                       event_script_callback, &status, false, call, fmt, ap);
+                       event_script_callback, &status, call, fmt, ap);
        va_end(ap);
        if (ret != 0) {
                return ret;
@@ -1060,7 +1037,7 @@ int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb,
 
        ret = ctdb_event_script_callback(ctdb, 
                         state, run_eventscripts_callback, state,
-                        true, call, "%s", options);
+                        call, "%s", options);
 
        if (ret != 0) {
                ctdb_enable_monitoring(ctdb);