ctdb-takeover: Send banning credit messages from fail callback
authorMartin Schwenke <martin@meltin.net>
Tue, 3 May 2016 05:09:25 +0000 (15:09 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 13 May 2016 11:47:17 +0000 (13:47 +0200)
Banning credits are now assigned by takeover runs called from all
locations in the recovery daemon.  Previously this only happened from
one of the callers.  When separating out the takeover run code the
behaviour should be consistent.

The callback (and corresponding data) passed to ctdb_takeover_run() is
now ignored.  Dropping this will allow the interface between the
recovery daemon and IP takeover to be simplified.

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

index dc5ce7da47cabfb9fbc6a3ec6c24613232c9a9a6..97b2c64e3026ef42c709f44657fdf1225d840d54 100644 (file)
@@ -1555,15 +1555,11 @@ fail:
 struct takeover_callback_data {
        uint32_t num_nodes;
        bool *node_failed;
-       client_async_callback fail_callback;
-       void *fail_callback_data;
 };
 
 static struct takeover_callback_data *
 takeover_callback_data_init(TALLOC_CTX *mem_ctx,
-                           uint32_t num_nodes,
-                           client_async_callback fail_callback,
-                           void *callback_data)
+                           uint32_t num_nodes)
 {
        static struct takeover_callback_data *takeover_data;
 
@@ -1582,8 +1578,6 @@ takeover_callback_data_init(TALLOC_CTX *mem_ctx,
        }
 
        takeover_data->num_nodes = num_nodes;
-       takeover_data->fail_callback = fail_callback;
-       takeover_data->fail_callback_data = callback_data;
 
        return takeover_data;
 }
@@ -1602,11 +1596,24 @@ static void takeover_run_fail_callback(struct ctdb_context *ctdb,
        }
 
        if (!cd->node_failed[node_pnn]) {
+               int ret;
+               TDB_DATA data;
+
                DEBUG(DEBUG_ERR,
                      ("Node %u failed the takeover run\n", node_pnn));
                cd->node_failed[node_pnn] = true;
-               cd->fail_callback(ctdb, node_pnn, res, outdata,
-                                 cd->fail_callback_data);
+
+               data.dptr = (uint8_t *)&node_pnn;
+               data.dsize = sizeof(uint32_t);
+               ret = ctdb_client_send_message(ctdb,
+                                              CTDB_BROADCAST_CONNECTED,
+                                              CTDB_SRVID_BANNING,
+                                              data);
+               if (ret != 0) {
+                       DEBUG(DEBUG_ERR,
+                             ("Failed to set banning credits for node %u\n",
+                              node_pnn));
+               }
        }
 }
 
@@ -1660,9 +1667,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodem
         * following steps will cause an early return, so this can be
         * reused for each of those steps without re-initialising. */
        takeover_data = takeover_callback_data_init(tmp_ctx,
-                                                   nodemap->num,
-                                                   fail_callback,
-                                                   callback_data);
+                                                   nodemap->num);
        if (takeover_data == NULL) {
                talloc_free(tmp_ctx);
                return -1;