mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
eventscript: save state for all script invocations
Rather than only tranferring to last_status for monitor events, do it for every event (ctdb->last_status is now an array). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (This used to be ctdb commit c73ea56275d4be76f7ed983d7565b20237dbdce3)
This commit is contained in:
parent
6960fa96eb
commit
d3593c2f83
@ -374,6 +374,21 @@ struct ctdb_write_record {
|
||||
unsigned char blob[1];
|
||||
};
|
||||
|
||||
/* different calls to event scripts. */
|
||||
enum ctdb_eventscript_call {
|
||||
CTDB_EVENT_STARTUP, /* CTDB starting up: no args. */
|
||||
CTDB_EVENT_START_RECOVERY, /* CTDB recovery starting: no args. */
|
||||
CTDB_EVENT_RECOVERED, /* CTDB recovery finished: no args. */
|
||||
CTDB_EVENT_TAKE_IP, /* IP taken: interface, IP address, netmask bits. */
|
||||
CTDB_EVENT_RELEASE_IP, /* IP released: interface, IP address, netmask bits. */
|
||||
CTDB_EVENT_STOPPED, /* This node is stopped: no args. */
|
||||
CTDB_EVENT_MONITOR, /* Please check if service is healthy: no args. */
|
||||
CTDB_EVENT_STATUS, /* Report service status: no args. */
|
||||
CTDB_EVENT_SHUTDOWN, /* CTDB shutting down: no args. */
|
||||
CTDB_EVENT_RELOAD, /* magic */
|
||||
CTDB_EVENT_MAX
|
||||
};
|
||||
|
||||
enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
|
||||
|
||||
#define CTDB_MONITORING_ACTIVE 0
|
||||
@ -455,7 +470,7 @@ struct ctdb_context {
|
||||
TALLOC_CTX *event_script_ctx;
|
||||
|
||||
struct ctdb_event_script_state *current_monitor;
|
||||
struct ctdb_scripts_wire *last_status;
|
||||
struct ctdb_scripts_wire *last_status[CTDB_EVENT_MAX];
|
||||
|
||||
TALLOC_CTX *banning_ctx;
|
||||
|
||||
@ -858,20 +873,6 @@ enum ctdb_trans2_commit_error {
|
||||
CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
|
||||
};
|
||||
|
||||
/* different calls to event scripts. */
|
||||
enum ctdb_eventscript_call {
|
||||
CTDB_EVENT_STARTUP, /* CTDB starting up: no args. */
|
||||
CTDB_EVENT_START_RECOVERY, /* CTDB recovery starting: no args. */
|
||||
CTDB_EVENT_RECOVERED, /* CTDB recovery finished: no args. */
|
||||
CTDB_EVENT_TAKE_IP, /* IP taken: interface, IP address, netmask bits. */
|
||||
CTDB_EVENT_RELEASE_IP, /* IP released: interface, IP address, netmask bits. */
|
||||
CTDB_EVENT_STOPPED, /* This node is stopped: no args. */
|
||||
CTDB_EVENT_MONITOR, /* Please check if service is healthy: no args. */
|
||||
CTDB_EVENT_STATUS, /* Report service status: no args. */
|
||||
CTDB_EVENT_SHUTDOWN, /* CTDB shutting down: no args. */
|
||||
CTDB_EVENT_RELOAD /* magic */
|
||||
};
|
||||
|
||||
/* internal prototypes */
|
||||
void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
|
||||
void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
|
||||
|
@ -116,11 +116,11 @@ static int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb,
|
||||
{
|
||||
DEBUG(DEBUG_INFO, ("event script finished called\n"));
|
||||
|
||||
talloc_free(ctdb->last_status);
|
||||
ctdb->last_status = talloc_steal(ctdb, state->scripts);
|
||||
talloc_free(ctdb->last_status[state->call]);
|
||||
ctdb->last_status[state->call] = talloc_steal(ctdb, state->scripts);
|
||||
/* if we didn't finish all the scripts, trim status array. */
|
||||
if (state->current < ctdb->last_status->num_scripts) {
|
||||
ctdb->last_status->num_scripts = state->current+1;
|
||||
if (state->current < ctdb->last_status[state->call]->num_scripts) {
|
||||
ctdb->last_status[state->call]->num_scripts = state->current+1;
|
||||
}
|
||||
state->scripts = NULL;
|
||||
|
||||
@ -129,7 +129,7 @@ static int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb,
|
||||
|
||||
int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb, TDB_DATA *outdata)
|
||||
{
|
||||
struct ctdb_scripts_wire *monitoring_scripts = ctdb->last_status;
|
||||
struct ctdb_scripts_wire *monitoring_scripts = ctdb->last_status[CTDB_EVENT_MONITOR];
|
||||
|
||||
if (monitoring_scripts == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " last_monitor_status_ctx is NULL when reading status\n"));
|
||||
@ -481,9 +481,7 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
|
||||
DEBUG(DEBUG_INFO,(__location__ " Eventscript %s %s finished with state %d\n",
|
||||
call_names[state->call], state->options, state->cb_status));
|
||||
|
||||
if (!state->from_user && state->call == CTDB_EVENT_MONITOR) {
|
||||
ctdb_control_event_script_finished(ctdb, state);
|
||||
}
|
||||
ctdb_control_event_script_finished(ctdb, state);
|
||||
ctdb->event_script_timeouts = 0;
|
||||
talloc_free(state);
|
||||
return;
|
||||
@ -496,9 +494,7 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
|
||||
state->current++;
|
||||
state->cb_status = fork_child_for_script(ctdb, state);
|
||||
if (state->cb_status != 0) {
|
||||
if (!state->from_user && state->call == CTDB_EVENT_MONITOR) {
|
||||
ctdb_control_event_script_finished(ctdb, state);
|
||||
}
|
||||
ctdb_control_event_script_finished(ctdb, state);
|
||||
/* This calls the callback. */
|
||||
talloc_free(state);
|
||||
}
|
||||
@ -521,10 +517,8 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
|
||||
state->child = 0;
|
||||
}
|
||||
|
||||
if (state->call == CTDB_EVENT_MONITOR || state->call == CTDB_EVENT_STATUS) {
|
||||
state->scripts->scripts[state->current].status = state->cb_status;
|
||||
ctdb_control_event_script_finished(ctdb, state);
|
||||
}
|
||||
state->scripts->scripts[state->current].status = state->cb_status;
|
||||
ctdb_control_event_script_finished(ctdb, state);
|
||||
|
||||
talloc_free(state);
|
||||
}
|
||||
@ -667,9 +661,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
|
||||
|
||||
/* Nothing to do? */
|
||||
if (state->scripts->num_scripts == 0) {
|
||||
if (!state->from_user && state->call == CTDB_EVENT_MONITOR) {
|
||||
ctdb_control_event_script_finished(ctdb, state);
|
||||
}
|
||||
ctdb_control_event_script_finished(ctdb, state);
|
||||
ctdb->event_script_timeouts = 0;
|
||||
talloc_free(state);
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user