check that a node is banned before trying to unban it.
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 12 May 2009 08:32:41 +0000 (18:32 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 12 May 2009 08:32:41 +0000 (18:32 +1000)
tools/ctdb.c

index ab631f85e0ab34381ade488161b3bfc20eb42dd9..35a4190eb738d2d64cf5d7718a251b202e4c3865 100644 (file)
@@ -1618,6 +1618,7 @@ static int control_unban(struct ctdb_context *ctdb, int argc, const char **argv)
        int ret;
        TDB_DATA data;
        uint32_t generation, next_generation;
+       struct ctdb_node_map *nodemap=NULL;
 
        /* record the current generation number */
        generation = get_generation(ctdb);
@@ -1625,6 +1626,17 @@ static int control_unban(struct ctdb_context *ctdb, int argc, const char **argv)
        data.dptr = (uint8_t *)&options.pnn;
        data.dsize = sizeof(uint32_t);
 
+       ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
+               return ret;
+       }
+
+       if (!(nodemap->nodes[options.pnn].flags & NODE_FLAGS_BANNED)) {
+               DEBUG(DEBUG_ERR, ("Node %d is not banned. Can not unban\n", options.pnn));
+               return -1;
+       }
+
        ret = ctdb_send_message(ctdb, options.pnn, CTDB_SRVID_UNBAN_NODE, data);
        if (ret != 0) {
                DEBUG(DEBUG_ERR,("Failed to to unban node %u\n", options.pnn));