ctdb-daemon: Stop inactive/disabled nodes from reporting available IPs
authorMartin Schwenke <martin@meltin.net>
Mon, 18 Jun 2018 06:22:14 +0000 (16:22 +1000)
committerAmitay Isaacs <amitay@samba.org>
Wed, 11 Jul 2018 09:48:38 +0000 (11:48 +0200)
This can be done now that NoIPHostOnAllDisabled is gone and will allow
the public IP address failover logic to be simplified.

In the test code, still filter available IP addresses by node state.
This code can't currently read information about available IP
addresses but that will change in future

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover.c
ctdb/tests/src/ctdb_takeover_tests.c
ctdb/tests/src/fake_ctdbd.c

index a4f0358f15007438a988b84f18ee0493287919b1..3f5536de3bb0490db6dccf35e24cf06a2bb31730 100644 (file)
@@ -299,6 +299,7 @@ static void ctdb_vnn_unassign_iface(struct ctdb_context *ctdb,
 static bool ctdb_vnn_available(struct ctdb_context *ctdb,
                               struct ctdb_vnn *vnn)
 {
+       uint32_t flags;
        struct vnn_interface *i;
 
        /* Nodes that are not RUNNING can not host IPs */
@@ -306,6 +307,11 @@ static bool ctdb_vnn_available(struct ctdb_context *ctdb,
                return false;
        }
 
+       flags = ctdb->nodes[ctdb->pnn]->flags;
+       if ((flags & (NODE_FLAGS_INACTIVE|NODE_FLAGS_DISABLED)) != 0) {
+               return false;
+       }
+
        if (vnn->delete_pending) {
                return false;
        }
index 86c167489110e92d9c083afc9e9fb829d99cbef1..5fe2bcf33f27f4961369f981beb1587194ad03d4 100644 (file)
@@ -160,6 +160,7 @@ static void ctdb_test_init(TALLOC_CTX *mem_ctx,
        uint32_t noiptakeover;
        ctdb_sock_addr sa_zero = { .ip = { 0 } };
        enum ipalloc_algorithm algorithm;
+       uint32_t n;
 
        /* Avoid that const */
        ns = talloc_strdup(mem_ctx, nodestates);
@@ -169,7 +170,7 @@ static void ctdb_test_init(TALLOC_CTX *mem_ctx,
        nodemap->num = 0;
        tok = strtok(ns, ",");
        while (tok != NULL) {
-               uint32_t n = nodemap->num;
+               n = nodemap->num;
                nodemap->node = talloc_realloc(nodemap, nodemap->node,
                                               struct ctdb_node_and_flags, n+1);
                nodemap->node[n].pnn = n;
@@ -212,6 +213,14 @@ static void ctdb_test_init(TALLOC_CTX *mem_ctx,
                                 read_ips_for_multiple_nodes,
                                 &known, &avail);
 
+       /* Drop available IPs for INACTIVE/DISABLED nodes */
+       for (n = 0; n < nodemap->num; n++) {
+               uint32_t flags = nodemap->node[n].flags;
+               if ((flags & (NODE_FLAGS_INACTIVE|NODE_FLAGS_DISABLED)) != 0) {
+                       avail[n].num = 0;
+               }
+       }
+
        ipalloc_set_public_ips(*ipalloc_state, known, avail);
 
        ipalloc_set_node_flags(*ipalloc_state, nodemap);
index 678116de5a4bc4687fa7846606f053d8094aa8a2..899d05f30d5ccf6148a8adf261e114b93d838818 100644 (file)
@@ -2630,7 +2630,9 @@ static void control_get_public_ips(TALLOC_CTX *mem_ctx,
                 * no available IPs.  Don't worry about interface
                 * states here - we're not faking down to that level.
                 */
-               if (ctdb->runstate != CTDB_RUNSTATE_RUNNING) {
+               uint32_t flags = ctdb->node_map->node[header->destnode].flags;
+               if (ctdb->runstate != CTDB_RUNSTATE_RUNNING ||
+                   ((flags & (NODE_FLAGS_INACTIVE|NODE_FLAGS_DISABLED)) != 0)) {
                        /* No available IPs: return dummy empty struct */
                        ips = talloc_zero(mem_ctx, struct ctdb_public_ip_list);;
                        if (ips == NULL) {