mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
ctdb-daemon: No need to call event scripts with CTDB_CALLED_BY_USER
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>
This commit is contained in:
parent
bafa467021
commit
7aa20ccb5c
@ -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);
|
||||
|
@ -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",
|
||||
"");
|
||||
|
@ -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", "");
|
||||
}
|
||||
}
|
||||
|
@ -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", "");
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user