ctdb-recoverd: Reload remote IPs as part of takeover run
authorMartin Schwenke <martin@meltin.net>
Wed, 28 Oct 2015 09:04:41 +0000 (20:04 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 12 Nov 2015 08:28:45 +0000 (09:28 +0100)
This is currently done before each IP takeover run, so just factor it
in.

ctdb_reload_remote_public_ips() becomes static.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Nov 12 09:28:45 CET 2015 on sn-devel-104

ctdb/include/ctdb_private.h
ctdb/server/ctdb_recoverd.c
ctdb/server/ctdb_takeover.c

index a2b187cf162c0016909851f26b5811a1276acc43..100b036c57631fc0c9a8b2836957fa1426bf0862 100644 (file)
@@ -961,8 +961,6 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses);
 int ctdb_set_single_public_ip(struct ctdb_context *ctdb, const char *iface,
                              const char *ip);
 
-int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
-                                 struct ctdb_node_map_old *nodemap);
 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap,
                      uint32_t *force_rebalance_nodes,
                      client_async_callback fail_callback, void *callback_data);
index 87c77950de6ea33cbe3dc25d990b35f2ce7915b9..be419fbf156ef69bfe92163296b6a44347decaa0 100644 (file)
@@ -2199,13 +2199,6 @@ static int do_recovery(struct ctdb_recoverd *rec,
                goto fail;
        }
 
-       /* Fetch known/available public IPs from each active node */
-       ret = ctdb_reload_remote_public_ips(ctdb, nodemap);
-       if (ret != 0) {
-               rec->need_takeover_run = true;
-               goto fail;
-       }
-
        do_takeover_run(rec, nodemap, false);
 
        /* execute the "recovered" event script on all nodes */
@@ -2728,19 +2721,10 @@ static void process_ipreallocate_requests(struct ctdb_context *ctdb,
        current = rec->reallocate_requests;
        rec->reallocate_requests = NULL;
 
-       /* update the list of public ips that a node can handle for
-          all connected nodes
-       */
-       ret = ctdb_reload_remote_public_ips(ctdb, rec->nodemap);
-       if (ret != 0) {
-               rec->need_takeover_run = true;
-       }
-       if (ret == 0) {
-               if (do_takeover_run(rec, rec->nodemap, false)) {
-                       ret = ctdb_get_pnn(ctdb);
-               } else {
-                       ret = -1;
-               }
+       if (do_takeover_run(rec, rec->nodemap, false)) {
+               ret = ctdb_get_pnn(ctdb);
+       } else {
+               ret = -1;
        }
 
        result.dsize = sizeof(int32_t);
@@ -3941,14 +3925,6 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 
        /* we might need to change who has what IP assigned */
        if (rec->need_takeover_run) {
-               /* update the list of public ips that a node can handle for
-                  all connected nodes
-               */
-               ret = ctdb_reload_remote_public_ips(ctdb, nodemap);
-               if (ret != 0) {
-                       return;
-               }
-
                /* If takeover run fails, then the offending nodes are
                 * assigned ban culprit counts. And we re-try takeover.
                 * If takeover run fails repeatedly, the node would get
index 27fb01aaf115d950b704b29be9501dbd048f212e..d21125a8696b961832d0785fb27abe3ef00c31be 100644 (file)
@@ -1392,8 +1392,8 @@ static int verify_remote_ip_allocation(struct ctdb_context *ctdb,
                                       struct ctdb_public_ip_list_old *ips,
                                       uint32_t pnn);
 
-int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
-                                 struct ctdb_node_map_old *nodemap)
+static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
+                                        struct ctdb_node_map_old *nodemap)
 {
        int j;
        int ret;
@@ -2671,6 +2671,13 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodem
                return -1;
        }
 
+       /* Fetch known/available public IPs from each active node */
+       ret = ctdb_reload_remote_public_ips(ctdb, nodemap);
+       if (ret != 0) {
+               talloc_free(tmp_ctx);
+               return -1;
+       }
+
        /* Short-circuit IP allocation if no nodes are in the RUNNING
         * runstate yet, since no nodes will be able to host IPs */
        can_host_ips = false;