Add a new event "ipreallocated"
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 30 Aug 2010 08:08:38 +0000 (18:08 +1000)
committerMichael Adam <obnox@samba.org>
Fri, 6 Jun 2014 13:00:34 +0000 (15:00 +0200)
    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.
(cherry picked from commit 7f4c591388adae20e98984001385cba26598ec67)

Conflicts:

include/ctdb_protocol.h

common/ctdb_util.c
config/events.d/11.natgw
include/ctdb.h
server/ctdb_takeover.c
server/eventscript.c

index 63abc02437820b78ca313a3284c3eaecfdc7eb76..10306eadf49895881acf493e7fd58199b49225ea 100644 (file)
@@ -671,5 +671,6 @@ const char *ctdb_eventscript_call_names[] = {
        "status",
        "shutdown",
        "reload",
+       "ipreallocated",
        "updateip"
 };
index b226b8110b369bc32fdc59de6aa3aac779a29f96..ba1d42dd5f21a053b2375605576ccb5d5d69528c 100644 (file)
@@ -35,7 +35,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/^[^ ]* *//"`
index ec1e5e66af045caa1375d9b72030f8b893470dc1..9aa03b76b5d3007c93b131ad292ff2abcf1d0c31 100644 (file)
@@ -704,6 +704,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
 };
 
index 73a4222748ccd6ec65ed85fe8ce746ae2a3a2e1d..a96463a652093772bb9bfa101bc646369de407ba 100644 (file)
@@ -1221,10 +1221,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;
@@ -1535,6 +1535,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;
 }
index a207bde885ee1969375786a28fe74ec48d54871b..af9fe345e01bc79d821e6f7486cfd57bfefd9971 100644 (file)
@@ -601,6 +601,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. */