1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

Add a new event "ipreallocated"

This is called everytime a reallocation is performed.

    While STARTRECOVERY/RECOVERED events are only called when
    we do ipreallocation as part of a full database/cluster recovery,
    this new event can be used to trigger on when we just do a light
    failover due to a node becomming unhealthy.

    I.e. situations where we do a failover but we do not perform a full
    cluster recovery.

    Use this to trigger for natgw so we select a new natgw master node
    when failover happens and not just when cluster rebuilds happen.

(This used to be ctdb commit 7f4c591388adae20e98984001385cba26598ec67)
This commit is contained in:
Ronnie Sahlberg 2010-08-30 18:08:38 +10:00
parent 3edec07807
commit c95f4258d8
5 changed files with 19 additions and 3 deletions

View File

@ -685,5 +685,6 @@ const char *ctdb_eventscript_call_names[] = {
"status",
"shutdown",
"reload",
"ipreallocated",
"updateip"
};

View File

@ -46,7 +46,7 @@ case "$1" in
ctdb setnatgwstate on
;;
recovered|updatenatgw)
recovered|updatenatgw|ipreallocated)
MYPNN=`ctdb pnn | cut -d: -f2`
NATGWMASTER=`ctdb natgwlist | head -1 | sed -e "s/ .*//"`
NATGWIP=`ctdb natgwlist | head -1 | sed -e "s/^[^ ]* *//"`

View File

@ -183,6 +183,7 @@ enum ctdb_eventscript_call {
CTDB_EVENT_SHUTDOWN, /* CTDB shutting down: no args. */
CTDB_EVENT_RELOAD, /* magic */
CTDB_EVENT_UPDATE_IP, /* IP updating: old interface, new interface, IP address, netmask bits. */
CTDB_EVENT_IPREALLOCATED, /* when a takeover_run() completes */
CTDB_EVENT_MAX
};

View File

@ -1215,10 +1215,10 @@ create_merged_ip_list(struct ctdb_context *ctdb)
*/
int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
{
int i, num_healthy, retries;
int i, num_healthy, retries, num_ips;
struct ctdb_public_ip ip;
struct ctdb_public_ipv4 ipv4;
uint32_t mask;
uint32_t mask, *nodes;
struct ctdb_public_ip_list *all_ips, *tmp_ip;
int maxnode, maxnum=0, minnode, minnum=0, num;
TDB_DATA data;
@ -1529,6 +1529,19 @@ finished:
return -1;
}
/* tell all nodes to update natwg */
/* send the flags update natgw on all connected nodes */
data.dptr = discard_const("ipreallocated");
data.dsize = strlen((char *)data.dptr) + 1;
nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
if (ctdb_client_async_control(ctdb, CTDB_CONTROL_RUN_EVENTSCRIPTS,
nodes, 0, TAKEOVER_TIMEOUT(),
false, data,
NULL, NULL,
NULL) != 0) {
DEBUG(DEBUG_ERR, (__location__ " ctdb_control to updatenatgw failed\n"));
}
talloc_free(tmp_ctx);
return 0;
}

View File

@ -633,6 +633,7 @@ static bool check_options(enum ctdb_eventscript_call call, const char *options)
case CTDB_EVENT_STATUS:
case CTDB_EVENT_SHUTDOWN:
case CTDB_EVENT_RELOAD:
case CTDB_EVENT_IPREALLOCATED:
return count_words(options) == 0;
case CTDB_EVENT_TAKE_IP: /* interface, IP address, netmask bits. */