]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
add a control to permanently enable/disable a node
authorRonnie Sahlberg <sahlberg@ronnie>
Wed, 6 Jun 2007 23:16:17 +0000 (09:16 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Wed, 6 Jun 2007 23:16:17 +0000 (09:16 +1000)
(This used to be ctdb commit d66fdba16ca22f62ddac6882a17614879b08a798)

ctdb/common/ctdb_client.c
ctdb/common/ctdb_control.c
ctdb/common/ctdb_monitor.c
ctdb/include/ctdb.h
ctdb/include/ctdb_private.h
ctdb/tools/ctdb_control.c

index eb3b67560f84106e08c20baea4dd9719c45af4ba..271a34085f9eed3b73172bd6eb24b8dd93b6f2d3 100644 (file)
@@ -1918,3 +1918,26 @@ int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb,
        return 0;
 }
 
+/*
+  set/clear the permanent disabled bit on a remote node
+ */
+int ctdb_ctrl_permdisable(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t mode)
+{
+       int ret;
+       TDB_DATA data;
+       int32_t res;
+
+       data.dsize = sizeof(uint32_t);
+       data.dptr = (unsigned char *)&mode;
+
+       ret = ctdb_control(ctdb, destnode, 0, 
+                          CTDB_CONTROL_PERMANENTLY_DISABLE, 0, data, 
+                          NULL, NULL, &res, &timeout, NULL);
+       if (ret != 0 || res != 0) {
+               DEBUG(0,(__location__ " ctdb_control for setpermdisable failed\n"));
+               return -1;
+       }
+
+       return 0;
+}
+
index ac2522131f67b52f0e83a6e75181742d4a4fa95c..83a4ee33a6472df8c302688b642e23a3e33a6ddc 100644 (file)
@@ -288,6 +288,15 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
        case CTDB_CONTROL_LIST_TUNABLES:
                return ctdb_control_list_tunables(ctdb, outdata);
 
+       case CTDB_CONTROL_PERMANENTLY_DISABLE:
+               CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
+               if ( *(uint32_t *)indata.dptr ){
+                       ctdb->nodes[ctdb->vnn]->flags |= NODE_FLAGS_PERMANENTLY_DISABLED;
+               } else {
+                       ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_PERMANENTLY_DISABLED;
+               }
+               return 0;
+
        default:
                DEBUG(0,(__location__ " Unknown CTDB control opcode %u\n", opcode));
                return -1;
index 166ee65df963e40d320c41d58a284b1e3b07c0ad..8461dca242c385be72388728a6ea62852ef3e2d6 100644 (file)
@@ -104,7 +104,12 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
                        timeval_current_ofs(ctdb->tunable.monitor_interval, 0), 
                        ctdb_check_health, ctdb);
 
-       if (status != 0 && !(node->flags & NODE_FLAGS_DISABLED)) {
+       if (node->flags & NODE_FLAGS_PERMANENTLY_DISABLED) {
+               if ( !(node->flags & NODE_FLAGS_DISABLED) ) {
+                       DEBUG(0,("monitoring - node is permanently disabled\n"));
+                       node->flags |= NODE_FLAGS_DISABLED;
+               }
+       } else if (status != 0 && !(node->flags & NODE_FLAGS_DISABLED)) {
                DEBUG(0,("monitor event failed - disabling node\n"));
                node->flags |= NODE_FLAGS_DISABLED;
        } else if (status == 0 && (node->flags & NODE_FLAGS_DISABLED)) {
index 8a19c19ec53c409ef13ad459c5466f8b5596b683..4e8fe4fa3c018094cc639ba3cc5b8e401d41b02e 100644 (file)
@@ -351,6 +351,9 @@ int ctdb_ctrl_list_tunables(struct ctdb_context *ctdb,
                            TALLOC_CTX *mem_ctx,
                            const char ***list, uint32_t *count);
 
-
+int ctdb_ctrl_permdisable(struct ctdb_context *ctdb, 
+                         struct timeval timeout, 
+                         uint32_t destnode, 
+                         uint32_t mode);
 
 #endif
index 0e5e361d70ccbc04299d2dbfab15a97ef14df109..c22c8a6d99665bac6e5288ad39a36eedda7e0c9e 100644 (file)
@@ -111,8 +111,9 @@ struct ctdb_node {
        const char *name; /* for debug messages */
        void *private_data; /* private to transport */
        uint32_t vnn;
-#define NODE_FLAGS_CONNECTED 0x00000001
-#define NODE_FLAGS_DISABLED  0x00000002
+#define NODE_FLAGS_CONNECTED           0x00000001
+#define NODE_FLAGS_DISABLED            0x00000002
+#define NODE_FLAGS_PERMANENTLY_DISABLED        0x00000004
        uint32_t flags;
 
        /* used by the dead node monitoring */
@@ -412,6 +413,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_GET_TUNABLE             = 49,
                    CTDB_CONTROL_LIST_TUNABLES           = 50,
                    CTDB_CONTROL_GET_PUBLIC_IPS          = 51,
+                   CTDB_CONTROL_PERMANENTLY_DISABLE     = 52,
 };
 
 /*
index d5ffbd96be1e57aeb88c4a7a9c9693ded9385a06..b0771689ee0b0e681fa9cd8945fc2b4804567e1f 100644 (file)
@@ -297,7 +297,9 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
        printf("Number of nodes:%d\n", nodemap->num);
        for(i=0;i<nodemap->num;i++){
                const char *flags_str;
-               if (nodemap->nodes[i].flags & NODE_FLAGS_DISABLED) {
+               if (nodemap->nodes[i].flags & NODE_FLAGS_PERMANENTLY_DISABLED) {
+                       flags_str = "PERM DISABLED";
+               } else if (nodemap->nodes[i].flags & NODE_FLAGS_DISABLED) {
                        flags_str = "DISABLED";
                } else if (nodemap->nodes[i].flags & NODE_FLAGS_CONNECTED) {
                        flags_str = "CONNECTED";
@@ -394,6 +396,38 @@ static int control_getpid(struct ctdb_context *ctdb, int argc, const char **argv
        return 0;
 }
 
+/*
+  disable a remote node
+ */
+static int control_disable(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       int ret;
+
+       ret = ctdb_ctrl_permdisable(ctdb, TIMELIMIT(), options.vnn, NODE_FLAGS_PERMANENTLY_DISABLED);
+       if (ret != 0) {
+               printf("Unable to disable node %u\n", options.vnn);
+               return ret;
+       }
+
+       return 0;
+}
+
+/*
+  enable a disabled remote node
+ */
+static int control_enable(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       int ret;
+
+       ret = ctdb_ctrl_permdisable(ctdb, TIMELIMIT(), options.vnn, 0);
+       if (ret != 0) {
+               printf("Unable to enable node %u\n", options.vnn);
+               return ret;
+       }
+
+       return 0;
+}
+
 /*
   shutdown a daemon
  */
@@ -835,6 +869,8 @@ static const struct {
        { "attach",          control_attach,            "attach to a database",                 "<dbname>" },
        { "dumpmemory",      control_dumpmemory,        "dump memory map to logs" },
        { "getpid",          control_getpid,            "get ctdbd process ID" },
+       { "disable",         control_disable,           "disable a node" },
+       { "enable",          control_enable,            "enable a node" },
        { "shutdown",        control_shutdown,          "shutdown ctdbd" },
        { "recover",         control_recover,           "force recovery" },
        { "freeze",          control_freeze,            "freeze all databases" },