ctdb-recoverd: Integrate takeover helper
authorMartin Schwenke <martin@meltin.net>
Fri, 9 Dec 2016 05:21:39 +0000 (16:21 +1100)
committerAmitay Isaacs <amitay@samba.org>
Mon, 19 Dec 2016 03:07:08 +0000 (04:07 +0100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_recoverd.c
ctdb/tests/simple/scripts/local_daemons.bash

index 12ab5635dbeebd70156accb48fd12a3faa7a7053..9ea0f616597e3b9a3519b33c9de6e25659fb8424 100644 (file)
@@ -1112,6 +1112,35 @@ fail:
 }
 
 
+static int ctdb_takeover(struct ctdb_recoverd *rec,
+                        uint32_t *force_rebalance_nodes)
+{
+       static char prog[PATH_MAX+1] = "";
+       char *arg;
+       int i;
+
+       if (!ctdb_set_helper("takeover_helper", prog, sizeof(prog),
+                            "CTDB_TAKEOVER_HELPER", CTDB_HELPER_BINDIR,
+                            "ctdb_takeover_helper")) {
+               ctdb_die(rec->ctdb, "Unable to set takeover helper\n");
+       }
+
+       arg = NULL;
+       for (i = 0; i < talloc_array_length(force_rebalance_nodes); i++) {
+               uint32_t pnn = force_rebalance_nodes[i];
+               if (arg == NULL) {
+                       arg = talloc_asprintf(rec, "%u", pnn);
+               } else {
+                       arg = talloc_asprintf_append(arg, ",%u", pnn);
+               }
+               if (arg == NULL) {
+                       DEBUG(DEBUG_ERR, (__location__ " memory error\n"));
+                       return -1;
+               }
+       }
+
+       return helper_run(rec, rec, prog, arg, "takeover");
+}
 
 static bool do_takeover_run(struct ctdb_recoverd *rec,
                            struct ctdb_node_map_old *nodemap)
@@ -1166,8 +1195,7 @@ static bool do_takeover_run(struct ctdb_recoverd *rec,
                }
        }
 
-       ret = ctdb_takeover_run(rec->ctdb, nodemap,
-                               rec->force_rebalance_nodes);
+       ret = ctdb_takeover(rec, rec->force_rebalance_nodes);
 
        /* Reenable takeover runs and IP checks on other nodes */
        dtr.timeout = 0;
index 18b58458fb09fdbea104854b1da9cfa4b59b2226..d7f33b6804e4b1b8cbc6bff65f79b464f0f601d3 100644 (file)
@@ -11,6 +11,7 @@ if [ -n "$ctdb_dir" -a -d "${ctdb_dir}/bin" ] ; then
        export CTDB_EVENT_HELPER="${hdir}/ctdb_event"
        export CTDB_LOCK_HELPER="${hdir}/ctdb_lock_helper"
        export CTDB_RECOVERY_HELPER="${hdir}/ctdb_recovery_helper"
+       export CTDB_TAKEOVER_HELPER="${hdir}/ctdb_takeover_helper"
        export CTDB_CLUSTER_MUTEX_HELPER="${hdir}/ctdb_mutex_fcntl_helper"
 fi