summaryrefslogtreecommitdiff
path: root/ctdb/tests/src
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2018-06-18 16:22:14 +1000
committerAmitay Isaacs <amitay@samba.org>2018-07-11 11:48:38 +0200
commit709ef6b7cc63ad272b959404d755af82c56d4ea0 (patch)
treec8940d67450e95a8beac02286d7408f0c9ab5702 /ctdb/tests/src
parentfda059108356bb97168f2cc61d94a18098cab0c4 (diff)
downloadsamba-709ef6b7cc63ad272b959404d755af82c56d4ea0.tar.gz
ctdb-daemon: Stop inactive/disabled nodes from reporting available IPs
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>
Diffstat (limited to 'ctdb/tests/src')
-rw-r--r--ctdb/tests/src/ctdb_takeover_tests.c11
-rw-r--r--ctdb/tests/src/fake_ctdbd.c4
2 files changed, 13 insertions, 2 deletions
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) {