summaryrefslogtreecommitdiffstats
path: root/ctdb/server/ctdb_monitor.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2009-10-14 11:59:16 +1100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2009-10-14 11:59:16 +1100
commit80be59d35e140783aa61a407c9ba031f31be2ed5 (patch)
tree1d350e55181914b82739a9eb870cec72f7531713 /ctdb/server/ctdb_monitor.c
parent4b7a208b16e86fb319f821ef6e8f0d334e9654a6 (diff)
downloadsamba-80be59d35e140783aa61a407c9ba031f31be2ed5.tar.gz
samba-80be59d35e140783aa61a407c9ba031f31be2ed5.tar.xz
samba-80be59d35e140783aa61a407c9ba031f31be2ed5.zip
when we change state between healthy/unhealthy, make sure we ask the recovery
master to perform an explicit ip reallocation. This is more reliable and faster than having the recovery dameon track these changes, and since we now have an explicit method to ask the recovery daemon to perform an explicit ip reallocation, we should use this. (This used to be ctdb commit 3807681e74f4bfe92befdae6ed616ff5f1a99880)
Diffstat (limited to 'ctdb/server/ctdb_monitor.c')
-rw-r--r--ctdb/server/ctdb_monitor.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c
index 4a554d45552..fc96fd71a2a 100644
--- a/ctdb/server/ctdb_monitor.c
+++ b/ctdb/server/ctdb_monitor.c
@@ -110,10 +110,19 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
TDB_DATA data;
struct ctdb_node_flag_change c;
uint32_t next_interval;
+ int ret;
+ TDB_DATA rddata;
+ struct takeover_run_reply rd;
c.pnn = ctdb->pnn;
c.old_flags = node->flags;
+ rd.pnn = ctdb->pnn;
+ rd.srvid = CTDB_SRVID_TAKEOVER_RUN_RESPONSE;
+
+ rddata.dptr = (uint8_t *)&rd;
+ rddata.dsize = sizeof(rd);
+
if (status != 0 && !(node->flags & NODE_FLAGS_UNHEALTHY)) {
DEBUG(DEBUG_NOTICE,("monitor event failed - disabling node\n"));
node->flags |= NODE_FLAGS_UNHEALTHY;
@@ -124,12 +133,28 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
}
ctdb_run_notification_script(ctdb, "unhealthy");
+
+ /* ask the recmaster to reallocate all addresses */
+ DEBUG(DEBUG_ERR,("Node became UNHEALTHY. Ask recovery master %u to perform ip reallocation\n", ctdb->recovery_master));
+ ret = ctdb_daemon_send_message(ctdb, ctdb->recovery_master, CTDB_SRVID_TAKEOVER_RUN, rddata);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,(__location__ " Failed to send ip takeover run request message to %u\n", ctdb->recovery_master));
+ }
+
} else if (status == 0 && (node->flags & NODE_FLAGS_UNHEALTHY)) {
DEBUG(DEBUG_NOTICE,("monitor event OK - node re-enabled\n"));
node->flags &= ~NODE_FLAGS_UNHEALTHY;
ctdb->monitor->next_interval = 1;
ctdb_run_notification_script(ctdb, "healthy");
+
+ /* ask the recmaster to reallocate all addresses */
+ DEBUG(DEBUG_ERR,("Node became HEALTHY. Ask recovery master %u to perform ip reallocation\n", ctdb->recovery_master));
+ ret = ctdb_daemon_send_message(ctdb, ctdb->recovery_master, CTDB_SRVID_TAKEOVER_RUN, rddata);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,(__location__ " Failed to send ip takeover run request message to %u\n", ctdb->recovery_master));
+ }
+
}
next_interval = ctdb->monitor->next_interval;