ctdb-ipalloc: ipalloc() returns public IP list
authorMartin Schwenke <martin@meltin.net>
Wed, 22 Jun 2016 04:22:02 +0000 (14:22 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 4 Jul 2016 13:42:25 +0000 (15:42 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover.c
ctdb/server/ipalloc.c
ctdb/server/ipalloc.h
ctdb/tests/src/ctdb_takeover_tests.c

index b696599579f4e9e5899af4bcdccd7ef727ca24ce..04c474e6e8113f8c38d641b8910b9867a64539f9 100644 (file)
@@ -1562,12 +1562,11 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodem
        }
 
        /* Do the IP reassignment calculations */
-       ipalloc(ipalloc_state);
-       if (ipalloc_state->all_ips == NULL) {
+       all_ips = ipalloc(ipalloc_state);
+       if (all_ips == NULL) {
                talloc_free(tmp_ctx);
                return -1;
        }
-       all_ips = ipalloc_state->all_ips;
 
        /* Now tell all nodes to release any public IPs should not
         * host.  This will be a NOOP on nodes that don't currently
index de6d94268ddd159a3ae641b760ba66c4cfc31473..dd88f81c29bf008a0b4c936806436ac6cd77828e 100644 (file)
@@ -265,7 +265,7 @@ bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state)
 }
 
 /* The calculation part of the IP allocation algorithm. */
-bool ipalloc(struct ipalloc_state *ipalloc_state)
+struct public_ip_list *ipalloc(struct ipalloc_state *ipalloc_state)
 {
        bool ret = false;
 
@@ -285,5 +285,5 @@ bool ipalloc(struct ipalloc_state *ipalloc_state)
           or -1 if there is no node that can cover this ip
        */
 
-       return ret;
+       return (ret ? ipalloc_state->all_ips : NULL);
 }
index 243d6af0c3a5c184d41b2adf3677eb565e195b0d..13fdfed36eb5832ee795dd82901d74441d507d73 100644 (file)
@@ -74,6 +74,6 @@ bool ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
 
 bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state);
 
-bool ipalloc(struct ipalloc_state *ipalloc_state);
+struct public_ip_list *ipalloc(struct ipalloc_state *ipalloc_state);
 
 #endif /* __CTDB_IPALLOC_H__ */
index d564e7b338c76323aa44dd3e21048265bfd0f6c9..46fc4970e233909df158cd4e6a34440de9276b0f 100644 (file)
@@ -332,9 +332,7 @@ static void ctdb_test_ipalloc(const char nodestates[],
        ctdb_test_init(nodestates, &ctdb, &ipalloc_state,
                       read_ips_for_multiple_nodes);
 
-       ipalloc(ipalloc_state);
-
-       print_ctdb_public_ip_list(ipalloc_state->all_ips);
+       print_ctdb_public_ip_list(ipalloc(ipalloc_state));
 
        talloc_free(ctdb);
 }