recoverd: Don't continue if the current node gets banned
authorMartin Schwenke <martin@meltin.net>
Fri, 28 Jun 2013 06:31:07 +0000 (16:31 +1000)
committerMichael Adam <obnox@samba.org>
Mon, 26 Aug 2013 11:35:55 +0000 (13:35 +0200)
Can not continue with recovery or monitoring cluster.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 14399de1dd0bd8dabf1f48b1457e3ccb37589d8a)

server/ctdb_recoverd.c

index 9c729bd9d1c61fffb4356abb649801b5e209c13b..2b16829540c554225cf5eb39ecf0332f6576c768 100644 (file)
@@ -1313,12 +1313,13 @@ static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
 }
 
 
-static void ban_misbehaving_nodes(struct ctdb_recoverd *rec)
+static void ban_misbehaving_nodes(struct ctdb_recoverd *rec, bool *self_ban)
 {
        struct ctdb_context *ctdb = rec->ctdb;
        int i;
        struct ctdb_banning_state *ban_state;
 
+       *self_ban = false;
        for (i=0; i<ctdb->num_nodes; i++) {
                if (ctdb->nodes[i]->ban_state == NULL) {
                        continue;
@@ -1333,6 +1334,11 @@ static void ban_misbehaving_nodes(struct ctdb_recoverd *rec)
                        ctdb->tunable.recovery_ban_period));
                ctdb_ban_node(rec, ctdb->nodes[i]->pnn, ctdb->tunable.recovery_ban_period);
                ban_state->count = 0;
+
+               /* Banning ourself? */
+               if (ctdb->nodes[i]->pnn == rec->ctdb->pnn) {
+                       *self_ban = true;
+               }
        }
 }
 
@@ -1352,13 +1358,18 @@ static int do_recovery(struct ctdb_recoverd *rec,
        uint32_t *nodes;
        struct timeval start_time;
        uint32_t culprit = (uint32_t)-1;
+       bool self_ban;
 
        DEBUG(DEBUG_NOTICE, (__location__ " Starting do_recovery\n"));
 
        /* if recovery fails, force it again */
        rec->need_recovery = true;
 
-       ban_misbehaving_nodes(rec);
+       ban_misbehaving_nodes(rec, &self_ban);
+       if (self_ban) {
+               DEBUG(DEBUG_NOTICE, ("This node was banned, aborting recovery\n"));
+               return -1;
+       }
 
         if (ctdb->tunable.verify_recovery_lock != 0) {
                DEBUG(DEBUG_ERR,("Taking out recovery lock from recovery daemon\n"));
@@ -2867,7 +2878,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
        struct ctdb_vnn_map *remote_vnnmap=NULL;
        int32_t debug_level;
        int i, j, ret;
-
+       bool self_ban;
 
 
        /* verify that the main daemon is still running */
@@ -2945,7 +2956,11 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
        /* remember our own node flags */
        rec->node_flags = nodemap->nodes[pnn].flags;
 
-       ban_misbehaving_nodes(rec);
+       ban_misbehaving_nodes(rec, &self_ban);
+       if (self_ban) {
+               DEBUG(DEBUG_NOTICE, ("This node was banned, restart main_loop\n"));
+               return;
+       }
 
        /* if the local daemon is STOPPED or BANNED, we verify that the databases are
           also frozen and thet the recmode is set to active.