mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
ctdb-daemon: Refactor check for valid events during recovery
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
c9a0f3015d
commit
21cac65b67
@ -737,6 +737,28 @@ schedule_callback_immediate(struct ctdb_context *ctdb,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* only specific events are allowed while in recovery */
|
||||||
|
static bool event_allowed_during_recovery(enum ctdb_event event)
|
||||||
|
{
|
||||||
|
const enum ctdb_event allowed_events[] = {
|
||||||
|
CTDB_EVENT_INIT,
|
||||||
|
CTDB_EVENT_SETUP,
|
||||||
|
CTDB_EVENT_START_RECOVERY,
|
||||||
|
CTDB_EVENT_SHUTDOWN,
|
||||||
|
CTDB_EVENT_RELEASE_IP,
|
||||||
|
CTDB_EVENT_IPREALLOCATED,
|
||||||
|
};
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(allowed_events); i++) {
|
||||||
|
if (event == allowed_events[i]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
run the event script in the background, calling the callback when
|
run the event script in the background, calling the callback when
|
||||||
finished
|
finished
|
||||||
@ -758,26 +780,11 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
|
|||||||
{
|
{
|
||||||
struct ctdb_event_script_state *state;
|
struct ctdb_event_script_state *state;
|
||||||
|
|
||||||
if (ctdb->recovery_mode != CTDB_RECOVERY_NORMAL) {
|
if ((ctdb->recovery_mode != CTDB_RECOVERY_NORMAL) &&
|
||||||
/* we guarantee that only some specifically allowed event scripts are run
|
(! event_allowed_during_recovery(call))) {
|
||||||
while in recovery */
|
DEBUG(DEBUG_ERR,
|
||||||
const enum ctdb_event allowed_calls[] = {
|
("Refusing to run event '%s' while in recovery\n",
|
||||||
CTDB_EVENT_INIT,
|
ctdb_eventscript_call_names[call]));
|
||||||
CTDB_EVENT_SETUP,
|
|
||||||
CTDB_EVENT_START_RECOVERY,
|
|
||||||
CTDB_EVENT_SHUTDOWN,
|
|
||||||
CTDB_EVENT_RELEASE_IP,
|
|
||||||
CTDB_EVENT_IPREALLOCATED,
|
|
||||||
};
|
|
||||||
int i;
|
|
||||||
for (i=0;i<ARRAY_SIZE(allowed_calls);i++) {
|
|
||||||
if (call == allowed_calls[i]) break;
|
|
||||||
}
|
|
||||||
if (i == ARRAY_SIZE(allowed_calls)) {
|
|
||||||
DEBUG(DEBUG_ERR,("Refusing to run event scripts call '%s' while in recovery\n",
|
|
||||||
ctdb_eventscript_call_names[call]));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do not run new monitor events if some event is already
|
/* Do not run new monitor events if some event is already
|
||||||
|
Loading…
Reference in New Issue
Block a user