NoIPTakeover: change the tunable name for the "dont allow failing addresses over...
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 22 Mar 2012 00:00:27 +0000 (11:00 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 22 Mar 2012 00:05:15 +0000 (11:05 +1100)
(This used to be ctdb commit 35592e618cfd827b6978af6332f80504f232c46a)

ctdb/doc/ctdbd.1.xml
ctdb/include/ctdb_private.h
ctdb/include/ctdb_protocol.h
ctdb/server/ctdb_takeover.c
ctdb/server/ctdb_tunables.c

index cf5b142c2b976cbeb1158a1beffe65414da1634d..5919675b81fb082ccbb9bb15508bcf3a542906e9 100644 (file)
     <refsect2><title>DisableIPFailover</title>
     <para>Default: 0</para>
     <para>
-    When enabled, ctdb weill not perform failover or failback. Even if a
+    When enabled, ctdb will not perform failover or failback. Even if a
     node fails while holding public IPs, ctdb will not recover the IPs or
     assign them to another node.
     </para>
     </para>
     </refsect2>
 
+    <refsect2><title>NoIPTakeover</title>
+    <para>Default: 0</para>
+    <para>
+    When set to 1, ctdb will allow ip addresses to be failed over onto this
+    node. Any ip addresses that the node currently hosts will remain on the
+    node but no new ip addresses can be failed over onto the node.
+    </para>
+    </refsect2>
+
     <refsect2><title>VerboseMemoryNames</title>
     <para>Default: 0</para>
     <para>
index c80cac550f61204e1c718b93ddf4462c0abb6926..3d5751b980851684bfa49cdb3091c56017ab2415 100644 (file)
@@ -130,6 +130,7 @@ struct ctdb_tunable {
        uint32_t hopcount_make_sticky;
        uint32_t sticky_duration;
        uint32_t sticky_pindown;
+       uint32_t no_ip_takeover;
 };
 
 /*
index ae989a95c9e2409228afd8390a3adcb2d0e8dbed..cb34fd5cf1582c6d1a48319a96cdab8e21575adf 100644 (file)
@@ -559,7 +559,7 @@ struct ctdb_node_map {
 #define NODE_FLAGS_DISABLED            (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
 #define NODE_FLAGS_INACTIVE            (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
 
-#define NODE_FLAGS_NOIPFAILBACK                0x01000000 /* this node can not be failed back onto, this flag is ONLY valid within the recovery daemon */
+#define NODE_FLAGS_NOIPTAKEOVER                0x01000000 /* this node can takeover any new ip addresses, this flag is ONLY valid within the recovery daemon */
 
 
 struct ctdb_public_ip {
index 0ed5132ab1b7a9f1d17b7d31e8efd0b900fa207f..1037c2f6bb1842525d1d05cb148cd0581048f876 100644 (file)
@@ -1175,7 +1175,7 @@ static int find_takeover_node(struct ctdb_context *ctdb,
 
        pnn    = -1;
        for (i=0;i<nodemap->num;i++) {
-               if (nodemap->nodes[i].flags & NODE_FLAGS_NOIPFAILBACK) {
+               if (nodemap->nodes[i].flags & NODE_FLAGS_NOIPTAKEOVER) {
                        /* This node is not allowed to takeover any addresses
                        */
                        continue;
@@ -1472,7 +1472,7 @@ static bool basic_failback(struct ctdb_context *ctdb,
                        }
 
                        /* Only check nodes that are allowed to takeover an ip */
-                       if (nodemap->nodes[i].flags & NODE_FLAGS_NOIPFAILBACK) {
+                       if (nodemap->nodes[i].flags & NODE_FLAGS_NOIPTAKEOVER) {
                                continue;
                        }
 
@@ -1652,7 +1652,7 @@ static void lcp2_allocate_unassigned(struct ctdb_context *ctdb,
 
                        for (dstnode=0; dstnode < nodemap->num; dstnode++) {
                                /* Only check nodes that are allowed to takeover an ip */
-                               if (nodemap->nodes[dstnode].flags & NODE_FLAGS_NOIPFAILBACK) {
+                               if (nodemap->nodes[dstnode].flags & NODE_FLAGS_NOIPTAKEOVER) {
                                        continue;
                                }
 
@@ -1766,7 +1766,7 @@ static bool lcp2_failback_candidate(struct ctdb_context *ctdb,
                        }
 
                        /* Only check nodes that are allowed to takeover an ip */
-                       if (nodemap->nodes[dstnode].flags & NODE_FLAGS_NOIPFAILBACK) {
+                       if (nodemap->nodes[dstnode].flags & NODE_FLAGS_NOIPTAKEOVER) {
                                continue;
                        }
 
@@ -2002,6 +2002,19 @@ try_again:
                basic_allocate_unassigned(ctdb, nodemap, mask, all_ips);
        }
 
+       /* If we dont want ips to fail back after a node becomes healthy
+          again, we wont even try to reallocat the ip addresses so that
+          they are evenly spread out.
+          This can NOT be used at the same time as DeterministicIPs !
+       */
+       if (1 == ctdb->tunable.no_ip_failback) {
+               if (1 == ctdb->tunable.deterministic_public_ips) {
+                       DEBUG(DEBUG_ERR, ("ERROR: You can not use 'DeterministicIPs' and 'NoIPFailback' at the same time\n"));
+               }
+               goto finished;
+       }
+
+
        /* now, try to make sure the ip adresses are evenly distributed
           across the node.
        */
@@ -2016,35 +2029,36 @@ try_again:
        }
 
        /* finished distributing the public addresses, now just send the 
-          info out to the nodes
-          at this point ->pnn is the node which will own each IP
+          info out to the nodes */
+finished:
+       /* at this point ->pnn is the node which will own each IP
           or -1 if there is no node that can cover this ip
        */
 
        return;
 }
 
-static void noipfailback_cb(struct ctdb_context *ctdb, uint32_t pnn, int32_t res, TDB_DATA outdata, void *callback)
+static void noiptakeover_cb(struct ctdb_context *ctdb, uint32_t pnn, int32_t res, TDB_DATA outdata, void *callback)
 {
        struct ctdb_node_map *nodemap = (struct ctdb_node_map *)callback;
 
        if (res != 0) {
-               DEBUG(DEBUG_ERR,("Failure to read NoIPFailback tunable from remote node %d\n", pnn));
+               DEBUG(DEBUG_ERR,("Failure to read NoIPTakeover tunable from remote node %d\n", pnn));
                return;
        }
 
        if (outdata.dsize != sizeof(uint32_t)) {
-               DEBUG(DEBUG_ERR,("Wrong size of returned data when reading NoIPFailback tunable from node %d. Expected %d bytes but received %d bytes\n", pnn, (int)sizeof(uint32_t), (int)outdata.dsize));
+               DEBUG(DEBUG_ERR,("Wrong size of returned data when reading NoIPTakeover tunable from node %d. Expected %d bytes but received %d bytes\n", pnn, (int)sizeof(uint32_t), (int)outdata.dsize));
                return;
        }
 
        if (pnn >= nodemap->num) {
-               DEBUG(DEBUG_ERR,("Got NoIPFailback reply from node %d but nodemap only has %d entries\n", pnn, nodemap->num));
+               DEBUG(DEBUG_ERR,("Got NoIPTakeover reply from node %d but nodemap only has %d entries\n", pnn, nodemap->num));
                return;
        }
 
        if (*(uint32_t *)outdata.dptr != 0) {
-               nodemap->nodes[pnn].flags |= NODE_FLAGS_NOIPFAILBACK;
+               nodemap->nodes[pnn].flags |= NODE_FLAGS_NOIPTAKEOVER;
        }
 }
 
@@ -2076,20 +2090,20 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
 
        /* assume all nodes do support failback */
        for (i=0;i<nodemap->num;i++) {
-               nodemap->nodes[i].flags &= ~NODE_FLAGS_NOIPFAILBACK;
+               nodemap->nodes[i].flags &= ~NODE_FLAGS_NOIPTAKEOVER;
        }
-       data.dsize = offsetof(struct ctdb_control_get_tunable, name) + strlen("NoIPFailback") + 1;
+       data.dsize = offsetof(struct ctdb_control_get_tunable, name) + strlen("NoIPTakeover") + 1;
        data.dptr  = talloc_size(tmp_ctx, data.dsize);
        t = (struct ctdb_control_get_tunable *)data.dptr;
-       t->length = strlen("NoIPFailback")+1;
-       memcpy(t->name, "NoIPFailback", t->length);
+       t->length = strlen("NoIPTakeover")+1;
+       memcpy(t->name, "NoIPTakeover", t->length);
        nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_GET_TUNABLE,
                                      nodes, 0, TAKEOVER_TIMEOUT(),
                                      false, data,
-                                     noipfailback_cb, NULL,
+                                     noiptakeover_cb, NULL,
                                      nodemap) != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " ctdb_control to get noipfailback tunable failed\n"));
+               DEBUG(DEBUG_ERR, (__location__ " ctdb_control to get noiptakeover tunable failed\n"));
        }
        talloc_free(nodes);
        talloc_free(data.dptr);
index 6a913e980088e8db8ee1a9691ff6b2c854ead230..41ff7ae7e89d5670512dc602021542e313e25fb0 100644 (file)
@@ -78,7 +78,8 @@ static const struct {
        { "MaxLACount",         20,  offsetof(struct ctdb_tunable, max_lacount) },
        { "HopcountMakeSticky",   50,  offsetof(struct ctdb_tunable, hopcount_make_sticky) },
        { "StickyDuration",      600,  offsetof(struct ctdb_tunable, sticky_duration) },
-       { "StickyPindown",       200,  offsetof(struct ctdb_tunable, sticky_pindown) }
+       { "StickyPindown",       200,  offsetof(struct ctdb_tunable, sticky_pindown) },
+       { "NoIPTakeover",         0,  offsetof(struct ctdb_tunable, no_ip_takeover), false }
 };
 
 /*