[SCM] CTDB repository - branch status-test-2 updated - ctdb-1.0.104-39-g28d0648
Ronnie Sahlberg
sahlberg at samba.org
Wed Nov 25 22:27:15 MST 2009
The branch, status-test-2 has been updated
via 28d0648725e7de4e4d0e8569e3fbfb0fa1d7f934 (commit)
via 143f1fa3cc4588505e3992c601153ea08be8432d (commit)
via a1d654a982ca56fade82552f4e6b5586236d3233 (commit)
from d3e7407dc9854ec358d081777c5450ec68b17862 (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=status-test-2
- Log -----------------------------------------------------------------
commit 28d0648725e7de4e4d0e8569e3fbfb0fa1d7f934
Merge: d3e7407dc9854ec358d081777c5450ec68b17862 143f1fa3cc4588505e3992c601153ea08be8432d
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Thu Nov 26 16:26:25 2009 +1100
Merge commit 'martins/status-test' into status-test-2
commit 143f1fa3cc4588505e3992c601153ea08be8432d
Merge: a2830594ebeb54eb51ff90999cb12370aeec6e8b a1d654a982ca56fade82552f4e6b5586236d3233
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Nov 26 16:25:15 2009 +1100
Merge commit 'martins-svart/status-test-2' into status-test
commit a1d654a982ca56fade82552f4e6b5586236d3233
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Nov 26 15:49:49 2009 +1100
Add flag to ctdb_event_script_callback indicating when called by client.
Signed-off-by: Martin Schwenke <martin at meltin.net>
-----------------------------------------------------------------------
Summary of changes:
include/ctdb_private.h | 6 ++++--
server/ctdb_monitor.c | 6 ++++--
server/ctdb_recover.c | 10 +++++++---
server/ctdb_takeover.c | 3 +++
server/eventscript.c | 37 +++++++++++++++++++++++--------------
5 files changed, 41 insertions(+), 21 deletions(-)
Changeset truncated at 500 lines:
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 05b288a..07f30f9 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -868,7 +868,8 @@ enum ctdb_eventscript_call {
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_SHUTDOWN, /* CTDB shutting down: no args. */
+ CTDB_EVENT_RELOAD /* magic */
};
/* internal prototypes */
@@ -1345,8 +1346,9 @@ 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(6,7);
+ const char *fmt, ...) PRINTF_ATTRIBUTE(7,8);
void ctdb_release_all_ips(struct ctdb_context *ctdb);
void set_nonblocking(int fd);
diff --git a/server/ctdb_monitor.c b/server/ctdb_monitor.c
index efb767a..437b9d8 100644
--- a/server/ctdb_monitor.c
+++ b/server/ctdb_monitor.c
@@ -224,7 +224,8 @@ static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
if (!ctdb->done_startup) {
ret = ctdb_event_script_callback(ctdb,
ctdb->monitor->monitor_context, ctdb_startup_callback,
- ctdb, CTDB_EVENT_STARTUP, "%s", "");
+ ctdb, false,
+ CTDB_EVENT_STARTUP, "%s", "");
} else {
int i;
int skip_monitoring = 0;
@@ -248,7 +249,8 @@ 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, CTDB_EVENT_MONITOR, "%s", "");
+ ctdb, false,
+ CTDB_EVENT_MONITOR, "%s", "");
}
}
diff --git a/server/ctdb_recover.c b/server/ctdb_recover.c
index 76b0a9b..da11bdb 100644
--- a/server/ctdb_recover.c
+++ b/server/ctdb_recover.c
@@ -964,7 +964,9 @@ int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb,
ret = ctdb_event_script_callback(ctdb, state,
ctdb_end_recovery_callback,
- state, CTDB_EVENT_RECOVERED, "%s", "");
+ state,
+ false,
+ CTDB_EVENT_RECOVERED, "%s", "");
if (ret != 0) {
ctdb_enable_monitoring(ctdb);
@@ -1016,7 +1018,8 @@ int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
ret = ctdb_event_script_callback(ctdb, state,
ctdb_start_recovery_callback,
- state, CTDB_EVENT_START_RECOVERY,
+ state, false,
+ CTDB_EVENT_START_RECOVERY,
"%s", "");
if (ret != 0) {
@@ -1229,7 +1232,8 @@ int32_t ctdb_control_stop_node(struct ctdb_context *ctdb, struct ctdb_req_contro
ret = ctdb_event_script_callback(ctdb, state,
ctdb_stop_node_callback,
- state, CTDB_EVENT_STOPPED, "%s", "");
+ state, false,
+ CTDB_EVENT_STOPPED, "%s", "");
if (ret != 0) {
ctdb_enable_monitoring(ctdb);
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index 6bc4e37..19b7085 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -236,6 +236,7 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
ret = ctdb_event_script_callback(ctdb,
state, takeover_ip_callback, state,
+ false,
CTDB_EVENT_TAKE_IP,
"%s %s %u",
vnn->iface,
@@ -392,6 +393,7 @@ 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",
vnn->iface,
@@ -2095,6 +2097,7 @@ 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",
vnn->iface,
diff --git a/server/eventscript.c b/server/eventscript.c
index a1ac36e..2508542 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -42,6 +42,7 @@ static const char *call_names[] = {
"monitor",
"status",
"shutdown",
+ "reload"
};
static void ctdb_event_script_timeout(struct event_context *ev, struct timed_event *te, struct timeval t, void *p);
@@ -461,6 +462,7 @@ static struct ctdb_script_list *ctdb_get_script_list(struct ctdb_context *ctdb,
which allows it to do blocking calls such as system()
*/
static int ctdb_run_event_script(struct ctdb_context *ctdb,
+ bool from_user,
enum ctdb_eventscript_call call,
const char *options)
{
@@ -469,7 +471,7 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
struct ctdb_script_list *scripts, *current;
- if (call == CTDB_EVENT_MONITOR) {
+ if (!from_user && call == CTDB_EVENT_MONITOR) {
/* This is running in the forked child process. At this stage
* we want to switch from being a ctdb daemon into being a
* client and connect to the real local daemon.
@@ -521,18 +523,23 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
them
*/
for (current=scripts; current; current=current->next) {
+ 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) {
- cmdstr = talloc_asprintf(tmp_ctx, "%s/%s %s",
+ && (call == CTDB_EVENT_MONITOR)
+ && !from_user) {
+ cmdstr = talloc_asprintf(tmp_ctx, "%s%s/%s %s",
+ str,
ctdb->event_script_dir,
current->name, "status");
} else {
- cmdstr = talloc_asprintf(tmp_ctx, "%s/%s %s %s",
+ cmdstr = talloc_asprintf(tmp_ctx, "%s%s/%s %s %s",
+ str,
ctdb->event_script_dir,
current->name, call_names[call], options);
}
@@ -543,7 +550,7 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
child_state.start = timeval_current();
child_state.script_running = cmdstr;
- if (call == CTDB_EVENT_MONITOR) {
+ if (!from_user && call == CTDB_EVENT_MONITOR) {
if (ctdb_ctrl_event_script_start(ctdb, current->name) != 0) {
DEBUG(DEBUG_ERR,(__location__ " Failed to start event script monitoring\n"));
talloc_free(tmp_ctx);
@@ -576,7 +583,7 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
DEBUG(DEBUG_ERR,("Script %s returned status 127. Someone just deleted it?\n", cmdstr));
}
- if (call == CTDB_EVENT_MONITOR) {
+ if (!from_user && call == CTDB_EVENT_MONITOR) {
if (ctdb_ctrl_event_script_stop(ctdb, ret) != 0) {
DEBUG(DEBUG_ERR,(__location__ " Failed to stop event script monitoring\n"));
talloc_free(tmp_ctx);
@@ -587,7 +594,7 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
/* return an error if the script failed */
if (ret != 0) {
DEBUG(DEBUG_ERR,("Event script %s failed with error %d\n", cmdstr, ret));
- if (call == CTDB_EVENT_MONITOR) {
+ if (!from_user && call == CTDB_EVENT_MONITOR) {
if (ctdb_ctrl_event_script_finished(ctdb) != 0) {
DEBUG(DEBUG_ERR,(__location__ " Failed to finish event script monitoring\n"));
talloc_free(tmp_ctx);
@@ -603,7 +610,7 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
child_state.start = timeval_current();
child_state.script_running = "finished";
- if (call == CTDB_EVENT_MONITOR) {
+ if (!from_user && call == CTDB_EVENT_MONITOR) {
if (ctdb_ctrl_event_script_finished(ctdb) != 0) {
DEBUG(DEBUG_ERR,(__location__ " Failed to finish event script monitoring\n"));
talloc_free(tmp_ctx);
@@ -786,6 +793,7 @@ static bool check_options(enum ctdb_eventscript_call call, const char *options)
static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
void (*callback)(struct ctdb_context *, int, void *),
void *private_data,
+ bool from_user,
enum ctdb_eventscript_call call,
const char *fmt, va_list ap)
{
@@ -793,7 +801,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
struct ctdb_event_script_state *state;
int ret;
- if (call == CTDB_EVENT_MONITOR || call == CTDB_EVENT_STATUS) {
+ if (!from_user && (call == CTDB_EVENT_MONITOR || call == CTDB_EVENT_STATUS)) {
/* if this was a "monitor" or a status event, we recycle the
context to start a new monitor event
*/
@@ -870,7 +878,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
close(state->fd[0]);
set_close_on_exec(state->fd[1]);
- rt = ctdb_run_event_script(ctdb, state->call, state->options);
+ rt = ctdb_run_event_script(ctdb, from_user, state->call, state->options);
/* 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));
@@ -906,6 +914,7 @@ 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, ...)
{
@@ -913,7 +922,7 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb,
int ret;
va_start(ap, fmt);
- ret = ctdb_event_script_callback_v(ctdb, callback, private_data, call, fmt, ap);
+ ret = ctdb_event_script_callback_v(ctdb, callback, private_data, from_user, call, fmt, ap);
va_end(ap);
return ret;
@@ -948,7 +957,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,
- event_script_callback, &status, call, fmt, ap);
+ event_script_callback, &status, false, call, fmt, ap);
if (ret != 0) {
return ret;
}
@@ -1048,9 +1057,9 @@ int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb,
ctdb_disable_monitoring(ctdb);
- ret = ctdb_event_script_callback(ctdb,
+ ret = ctdb_event_script_callback(ctdb,
state, run_eventscripts_callback, state,
- call, "%s", options);
+ true, call, "%s", options);
if (ret != 0) {
ctdb_enable_monitoring(ctdb);
--
CTDB repository
More information about the samba-cvs
mailing list