summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2017-02-03 15:31:00 +1100
committerMartin Schwenke <martins@samba.org>2017-02-24 07:47:12 +0100
commit4556bdc7d6b36ddc5a6d3020e784aaa157e5fed5 (patch)
tree67173c87134ae4b7d0f9a9de48d07228807e8dde
parent04cddae17d3b3a640225209d7a2e2e2ea7367783 (diff)
downloadsamba-4556bdc7d6b36ddc5a6d3020e784aaa157e5fed5.tar.gz
ctdb-takeover: Only fetch available IPs from nodes with known IPs
A simple optimisation to avoid unnecessary communication. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
-rw-r--r--ctdb/server/ctdb_takeover_helper.c22
-rwxr-xr-xctdb/tests/takeover_helper/031.sh55
2 files changed, 76 insertions, 1 deletions
diff --git a/ctdb/server/ctdb_takeover_helper.c b/ctdb/server/ctdb_takeover_helper.c
index d359cf913ba..e56c94ac9a2 100644
--- a/ctdb/server/ctdb_takeover_helper.c
+++ b/ctdb/server/ctdb_takeover_helper.c
@@ -866,6 +866,8 @@ static void takeover_known_ips_done(struct tevent_req *subreq)
req, struct takeover_state);
int ret;
bool status;
+ uint32_t *pnns = NULL;
+ int count, i;
status = get_public_ips_recv(subreq, &ret, state, &state->known_ips);
TALLOC_FREE(subreq);
@@ -876,8 +878,26 @@ static void takeover_known_ips_done(struct tevent_req *subreq)
return;
}
+ /* Get available IPs from active nodes that actually have known IPs */
+
+ pnns = talloc_zero_array(state, uint32_t, state->num_active);
+ if (tevent_req_nomem(pnns, req)) {
+ return;
+ }
+
+ count = 0;
+ for (i = 0; i < state->num_active; i++) {
+ uint32_t pnn = state->pnns_active[i];
+
+ /* If pnn has IPs then fetch available IPs from it */
+ if (state->known_ips[pnn].num > 0) {
+ pnns[count] = pnn;
+ count++;
+ }
+ }
+
subreq = get_public_ips_send(state, state->ev, state->client,
- state->pnns_active, state->num_active,
+ pnns, count,
state->num_nodes, true);
if (tevent_req_nomem(subreq, req)) {
return;
diff --git a/ctdb/tests/takeover_helper/031.sh b/ctdb/tests/takeover_helper/031.sh
new file mode 100755
index 00000000000..435cd499d6f
--- /dev/null
+++ b/ctdb/tests/takeover_helper/031.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "3 nodes, all ok, IPs defined on 2, IPs all unassigned"
+
+setup_ctdbd <<EOF
+NODEMAP
+0 192.168.20.41 0x0 CURRENT RECMASTER
+1 192.168.20.42 0x0
+2 192.168.20.43 0x0
+
+IFACES
+:Name:LinkStatus:References:
+:eth2:1:2:
+:eth1:1:4:
+
+PUBLICIPS
+10.0.0.31 -1 0,2
+10.0.0.32 -1 0,2
+10.0.0.33 -1 0,2
+10.0.0.34 -1 0,2
+EOF
+
+HELPER_DEBUGLEVEL=INFO
+ok <<EOF
+Fetched public IPs from node 0
+Fetched public IPs from node 1
+Fetched public IPs from node 2
+Fetched public IPs from node 0
+Fetched public IPs from node 2
+ 10.0.0.34 -> 0 [+0]
+ 10.0.0.33 -> 2 [+0]
+ 10.0.0.31 -> 0 [+14884]
+ 10.0.0.32 -> 2 [+16129]
+RELEASE_IP 10.0.0.34 succeeded on 2 nodes
+RELEASE_IP 10.0.0.33 succeeded on 2 nodes
+RELEASE_IP 10.0.0.32 succeeded on 2 nodes
+RELEASE_IP 10.0.0.31 succeeded on 2 nodes
+TAKEOVER_IP 10.0.0.34 succeeded on node 0
+TAKEOVER_IP 10.0.0.33 succeeded on node 2
+TAKEOVER_IP 10.0.0.32 succeeded on node 2
+TAKEOVER_IP 10.0.0.31 succeeded on node 0
+IPREALLOCATED succeeded on 3 nodes
+EOF
+test_takeover_helper
+
+required_result 0 <<EOF
+Public IPs on ALL nodes
+10.0.0.31 0
+10.0.0.32 2
+10.0.0.33 2
+10.0.0.34 0
+EOF
+test_ctdb_ip_all