ctdb-recoverd: Short circuit takeover run if no nodes are RUNNING
authorMartin Schwenke <martin@meltin.net>
Fri, 19 Dec 2014 04:08:40 +0000 (15:08 +1100)
committerAmitay Isaacs <amitay@samba.org>
Sun, 10 May 2015 01:22:13 +0000 (03:22 +0200)
If all nodes are still in, say, FIRST_RECOVERY runstate, then the logs
contain unfortunate noise like:

  recoverd:Failed to find node to cover ip 10.0.2.131

This avoids that by adding an early exit that avoids running
takeover_run_core() when there are no nodes in the
CTDB_RUNSTATE_RUNNING.

To support this add the runstate to the ipflags structure.  There are
clearly other ways of hacking this but this seems the simplest.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover.c

index cf1a1c30fbcbf7aca6dfcdc3b5ce109fd5222141..6509ebfec3a086c6815d10063cf13cf292d3a568 100644 (file)
@@ -37,6 +37,7 @@
 struct ctdb_ipflags {
        bool noiptakeover;
        bool noiphost;
+       enum ctdb_runstate runstate;
 };
 
 struct ctdb_iface {
@@ -2474,6 +2475,8 @@ set_ipflags_internal(struct ctdb_context *ctdb,
                if (nodemap->nodes[i].flags & NODE_FLAGS_INACTIVE) {
                        ipflags[i].noiphost = true;
                }
+               /* Remember the runstate */
+               ipflags[i].runstate = runstate[i];
        }
 
        if (all_nodes_are_disabled(nodemap)) {
@@ -2663,6 +2666,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap,
        struct takeover_callback_data *takeover_data;
        struct iprealloc_callback_data iprealloc_data;
        bool *retry_data;
+       bool can_host_ips;
 
        /*
         * ip failover is completely disabled, just send out the 
@@ -2679,6 +2683,19 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap,
                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;
+       for (i=0; i<nodemap->num; i++) {
+               if (ipflags[i].runstate == CTDB_RUNSTATE_RUNNING) {
+                       can_host_ips = true;
+               }
+       }
+       if (!can_host_ips) {
+               DEBUG(DEBUG_WARNING,("No nodes available to host public IPs yet\n"));
+               return 0;
+       }
+
        /* Do the IP reassignment calculations */
        ctdb_takeover_run_core(ctdb, ipflags, &all_ips, force_rebalance_nodes);