ctdb-takeover: Drop ipreallocated fallback code
authorMartin Schwenke <martin@meltin.net>
Tue, 3 May 2016 04:14:53 +0000 (14:14 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 13 May 2016 11:47:16 +0000 (13:47 +0200)
The ipreallocated control has been in CTDB for a long time.

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

index 5001489ef180e3b6e93dc92ef641e9b9a26086c3..247d52ff035a1c24c1570eae2494df041c0c6f93 100644 (file)
@@ -1552,68 +1552,6 @@ fail:
        return NULL;
 }
 
-struct iprealloc_callback_data {
-       bool *retry_nodes;
-       int retry_count;
-       client_async_callback fail_callback;
-       void *fail_callback_data;
-       struct ctdb_node_map_old *nodemap;
-};
-
-static void iprealloc_fail_callback(struct ctdb_context *ctdb, uint32_t pnn,
-                                       int32_t res, TDB_DATA outdata,
-                                       void *callback)
-{
-       int numnodes;
-       struct iprealloc_callback_data *cd =
-               (struct iprealloc_callback_data *)callback;
-
-       numnodes = talloc_array_length(cd->retry_nodes);
-       if (pnn > numnodes) {
-               DEBUG(DEBUG_ERR,
-                     ("ipreallocated failure from node %d, "
-                      "but only %d nodes in nodemap\n",
-                      pnn, numnodes));
-               return;
-       }
-
-       /* Can't run the "ipreallocated" event on a INACTIVE node */
-       if (cd->nodemap->nodes[pnn].flags & NODE_FLAGS_INACTIVE) {
-               DEBUG(DEBUG_WARNING,
-                     ("ipreallocated failed on inactive node %d, ignoring\n",
-                      pnn));
-               return;
-       }
-
-       switch (res) {
-       case -ETIME:
-               /* If the control timed out then that's a real error,
-                * so call the real fail callback
-                */
-               if (cd->fail_callback) {
-                       cd->fail_callback(ctdb, pnn, res, outdata,
-                                         cd->fail_callback_data);
-               } else {
-                       DEBUG(DEBUG_WARNING,
-                             ("iprealloc timed out but no callback registered\n"));
-               }
-               break;
-       default:
-               /* If not a timeout then either the ipreallocated
-                * eventscript (or some setup) failed.  This might
-                * have failed because the IPREALLOCATED control isn't
-                * implemented - right now there is no way of knowing
-                * because the error codes are all folded down to -1.
-                * Consider retrying using EVENTSCRIPT control...
-                */
-               DEBUG(DEBUG_WARNING,
-                     ("ipreallocated failure from node %d, flagging retry\n",
-                      pnn));
-               cd->retry_nodes[pnn] = true;
-               cd->retry_count++;
-       }
-}
-
 struct takeover_callback_data {
        bool *node_failed;
        client_async_callback fail_callback;
@@ -1680,7 +1618,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodem
                      uint32_t *force_rebalance_nodes,
                      client_async_callback fail_callback, void *callback_data)
 {
-       int i, j, ret;
+       int i, ret;
        struct ctdb_public_ip ip;
        uint32_t *nodes;
        struct public_ip_list *all_ips, *tmp_ip;
@@ -1691,8 +1629,6 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodem
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
        struct ipalloc_state *ipalloc_state;
        struct takeover_callback_data *takeover_data;
-       struct iprealloc_callback_data iprealloc_data;
-       bool *retry_data;
        bool can_host_ips;
 
        /*
@@ -1865,54 +1801,15 @@ ipreallocated:
         * IPs have moved.  Once upon a time this event only used to
         * update natgw.
         */
-       retry_data = talloc_zero_array(tmp_ctx, bool, nodemap->num);
-       CTDB_NO_MEMORY_FATAL(ctdb, retry_data);
-       iprealloc_data.retry_nodes = retry_data;
-       iprealloc_data.retry_count = 0;
-       iprealloc_data.fail_callback = fail_callback;
-       iprealloc_data.fail_callback_data = callback_data;
-       iprealloc_data.nodemap = nodemap;
-
        nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
        ret = ctdb_client_async_control(ctdb, CTDB_CONTROL_IPREALLOCATED,
                                        nodes, 0, TAKEOVER_TIMEOUT(),
                                        false, tdb_null,
-                                       NULL, iprealloc_fail_callback,
-                                       &iprealloc_data);
+                                       NULL, fail_callback,
+                                       &callback_data);
        if (ret != 0) {
-               /* If the control failed then we should retry to any
-                * nodes flagged by iprealloc_fail_callback using the
-                * EVENTSCRIPT control.  This is a best-effort at
-                * backward compatiblity when running a mixed cluster
-                * where some nodes have not yet been upgraded to
-                * support the IPREALLOCATED control.
-                */
-               DEBUG(DEBUG_WARNING,
-                     ("Retry ipreallocated to some nodes using eventscript control\n"));
-
-               nodes = talloc_array(tmp_ctx, uint32_t,
-                                    iprealloc_data.retry_count);
-               CTDB_NO_MEMORY_FATAL(ctdb, nodes);
-
-               j = 0;
-               for (i=0; i<nodemap->num; i++) {
-                       if (iprealloc_data.retry_nodes[i]) {
-                               nodes[j] = i;
-                               j++;
-                       }
-               }
-
-               data.dptr  = discard_const("ipreallocated");
-               data.dsize = strlen((char *)data.dptr) + 1; 
-               ret = ctdb_client_async_control(ctdb,
-                                               CTDB_CONTROL_RUN_EVENTSCRIPTS,
-                                               nodes, 0, TAKEOVER_TIMEOUT(),
-                                               false, data,
-                                               NULL, fail_callback,
-                                               callback_data);
-               if (ret != 0) {
-                       DEBUG(DEBUG_ERR, (__location__ " failed to send control to run eventscripts with \"ipreallocated\"\n"));
-               }
+               DEBUG(DEBUG_ERR,
+                     ("Async CTDB_CONTROL_IPREALLOCATED control failed\n"));
        }
 
        talloc_free(tmp_ctx);