When trying to enable/disable a node.
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 3 Feb 2010 23:03:21 +0000 (10:03 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 3 Feb 2010 23:03:21 +0000 (10:03 +1100)
Check if the node is already enabled/disabled and log an information
message if so.

tools/ctdb.c

index 9d6547c55c8016da34cc714c6ba9fd484eedfc27..1c760d40a8043fdee9c9d341eb0a2f1152dda006 100644 (file)
@@ -2085,6 +2085,16 @@ static int control_disable(struct ctdb_context *ctdb, int argc, const char **arg
        int ret;
        struct ctdb_node_map *nodemap=NULL;
 
+       /* check if the node is already disabled */
+       if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap) != 0) {
+               DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
+               exit(10);
+       }
+       if (nodemap->nodes[options.pnn].flags & NODE_FLAGS_PERMANENTLY_DISABLED) {
+               DEBUG(DEBUG_ERR,("Node %d is already disabled.\n", options.pnn));
+               return 0;
+       }
+
        do {
                ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.pnn, NODE_FLAGS_PERMANENTLY_DISABLED, 0);
                if (ret != 0) {
@@ -2119,6 +2129,16 @@ static int control_enable(struct ctdb_context *ctdb, int argc, const char **argv
 
        struct ctdb_node_map *nodemap=NULL;
 
+       /* check if the node is already enabled */
+       if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap) != 0) {
+               DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
+               exit(10);
+       }
+       if (!(nodemap->nodes[options.pnn].flags & NODE_FLAGS_PERMANENTLY_DISABLED)) {
+               DEBUG(DEBUG_ERR,("Node %d is already enabled.\n", options.pnn));
+               return 0;
+       }
+
        do {
                ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.pnn, 0, NODE_FLAGS_PERMANENTLY_DISABLED);
                if (ret != 0) {