diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index a4f0358f150..3f5536de3bb 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -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; } diff --git a/ctdb/tests/src/ctdb_takeover_tests.c b/ctdb/tests/src/ctdb_takeover_tests.c index 86c16748911..5fe2bcf33f2 100644 --- a/ctdb/tests/src/ctdb_takeover_tests.c +++ b/ctdb/tests/src/ctdb_takeover_tests.c @@ -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); diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c index 678116de5a4..899d05f30d5 100644 --- a/ctdb/tests/src/fake_ctdbd.c +++ b/ctdb/tests/src/fake_ctdbd.c @@ -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) {