summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2009-07-09 11:38:18 +1000
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2009-07-09 11:38:18 +1000
commit9f0dc4b93b4bbf12c477700e342972eaf02293b2 (patch)
tree316dd38bc94709d498b12f3b31c49bf74d45a740
parentd6862832edfcfe7a4bf3039626706d501483ea1a (diff)
downloadsamba-9f0dc4b93b4bbf12c477700e342972eaf02293b2.tar.gz
samba-9f0dc4b93b4bbf12c477700e342972eaf02293b2.tar.xz
samba-9f0dc4b93b4bbf12c477700e342972eaf02293b2.zip
Add a new node flag : STOPPED
This node flag means the node is DISABLED and that all its public ip addresses are failed over, but also that it has been removed from the VNNmap. A STOPPED node should be in recovery mode active untill restarted using the continue command. Adding two new commands "ctdb stop" "ctdb continue" (This used to be ctdb commit d47dab1026deba0554f21282a59bd172209ea066)
-rw-r--r--ctdb/include/ctdb_private.h3
-rw-r--r--ctdb/tools/ctdb.c83
2 files changed, 80 insertions, 6 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 4abe2368bf..930fa17543 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -197,8 +197,9 @@ struct ctdb_node {
#define NODE_FLAGS_UNHEALTHY 0x00000002 /* monitoring says node is unhealthy */
#define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 /* administrator has disabled node */
#define NODE_FLAGS_BANNED 0x00000008 /* recovery daemon has banned the node */
-#define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
#define NODE_FLAGS_DELETED 0x00000010 /* this node has been deleted */
+#define NODE_FLAGS_STOPPED 0x00000020 /* this node has been stopped */
+#define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED|NODE_FLAGS_STOPPED)
#define NODE_FLAGS_INACTIVE (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED)
uint32_t flags;
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 3ba4db9e66..c16843d1dd 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -503,17 +503,18 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
}
if(options.machinereadable){
- printf(":Node:IP:Disconnected:Banned:Disabled:Unhealthy:\n");
+ printf(":Node:IP:Disconnected:Banned:Disabled:Unhealthy:Stopped:\n");
for(i=0;i<nodemap->num;i++){
if (nodemap->nodes[i].flags & NODE_FLAGS_DELETED) {
continue;
}
- printf(":%d:%s:%d:%d:%d:%d:\n", nodemap->nodes[i].pnn,
+ printf(":%d:%s:%d:%d:%d:%d:%d:\n", nodemap->nodes[i].pnn,
ctdb_addr_to_str(&nodemap->nodes[i].addr),
!!(nodemap->nodes[i].flags&NODE_FLAGS_DISCONNECTED),
!!(nodemap->nodes[i].flags&NODE_FLAGS_BANNED),
!!(nodemap->nodes[i].flags&NODE_FLAGS_PERMANENTLY_DISABLED),
- !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY));
+ !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY),
+ !!(nodemap->nodes[i].flags&NODE_FLAGS_STOPPED));
}
return 0;
}
@@ -529,6 +530,7 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
{ NODE_FLAGS_BANNED, "BANNED" },
{ NODE_FLAGS_UNHEALTHY, "UNHEALTHY" },
{ NODE_FLAGS_DELETED, "DELETED" },
+ { NODE_FLAGS_STOPPED, "STOPPED" },
};
char *flags_str = NULL;
int j;
@@ -685,15 +687,17 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
/* print the pruned list of nodes belonging to this natgw list */
for(i=0;i<nodemap->num;i++){
+ printf(":Node:IP:Disconnected:Banned:Disabled:Unhealthy:Stopped:\n");
if (nodemap->nodes[i].flags & NODE_FLAGS_DELETED) {
continue;
}
- printf(":%d:%s:%d:%d:%d:%d:\n", nodemap->nodes[i].pnn,
+ printf(":%d:%s:%d:%d:%d:%d:%d\n", nodemap->nodes[i].pnn,
ctdb_addr_to_str(&nodemap->nodes[i].addr),
!!(nodemap->nodes[i].flags&NODE_FLAGS_DISCONNECTED),
!!(nodemap->nodes[i].flags&NODE_FLAGS_BANNED),
!!(nodemap->nodes[i].flags&NODE_FLAGS_PERMANENTLY_DISABLED),
- !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY));
+ !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY),
+ !!(nodemap->nodes[i].flags&NODE_FLAGS_STOPPED));
}
return 0;
@@ -1651,6 +1655,73 @@ static int control_enable(struct ctdb_context *ctdb, int argc, const char **argv
return 0;
}
+/*
+ stop a remote node
+ */
+static int control_stop(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ int ret;
+ struct ctdb_node_map *nodemap=NULL;
+
+ do {
+ ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.pnn, NODE_FLAGS_STOPPED, 0);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("Unable to stop node %u\n", options.pnn));
+ return ret;
+ }
+
+ sleep(1);
+
+ /* read the nodemap and verify the change took effect */
+ 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);
+ }
+
+ } while (!(nodemap->nodes[options.pnn].flags & NODE_FLAGS_STOPPED));
+ ret = control_ipreallocate(ctdb, argc, argv);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("IP Reallocate failed on node %u\n", options.pnn));
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
+ restart a stopped remote node
+ */
+static int control_continue(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ int ret;
+
+ struct ctdb_node_map *nodemap=NULL;
+
+ do {
+ ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.pnn, 0, NODE_FLAGS_STOPPED);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("Unable to restart node %u\n", options.pnn));
+ return ret;
+ }
+
+ sleep(1);
+
+ /* read the nodemap and verify the change took effect */
+ 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);
+ }
+
+ } while (nodemap->nodes[options.pnn].flags & NODE_FLAGS_STOPPED);
+ ret = control_ipreallocate(ctdb, argc, argv);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("IP Reallocate failed on node %u\n", options.pnn));
+ return ret;
+ }
+
+ return 0;
+}
+
static uint32_t get_generation(struct ctdb_context *ctdb)
{
struct ctdb_vnn_map *vnnmap=NULL;
@@ -3070,6 +3141,8 @@ static const struct {
{ "getpid", control_getpid, true, false, "get ctdbd process ID" },
{ "disable", control_disable, true, false, "disable a nodes public IP" },
{ "enable", control_enable, true, false, "enable a nodes public IP" },
+ { "stop", control_stop, true, false, "stop a node" },
+ { "continue", control_continue, true, false, "re-start a stopped node" },
{ "ban", control_ban, true, false, "ban a node from the cluster", "<bantime|0>"},
{ "unban", control_unban, true, false, "unban a node from the cluster" },
{ "shutdown", control_shutdown, true, false, "shutdown ctdbd" },