case CTDB_CONTROL_LIST_TUNABLES:
return ctdb_control_list_tunables(ctdb, outdata);
- 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;
+ case CTDB_CONTROL_PERMANENTLY_DISABLE:
+ CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
++ return ctdb_control_permdisable(ctdb, indata);
+
default:
DEBUG(0,(__location__ " Unknown CTDB control opcode %u\n", opcode));
return -1;
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)) {
++ if (status != 0 && !(node->flags & NODE_FLAGS_UNHEALTHY)) {
DEBUG(0,("monitor event failed - disabling node\n"));
-- node->flags |= NODE_FLAGS_DISABLED;
-- } else if (status == 0 && (node->flags & NODE_FLAGS_DISABLED)) {
++ node->flags |= NODE_FLAGS_UNHEALTHY;
++ } else if (status == 0 && (node->flags & NODE_FLAGS_UNHEALTHY)) {
DEBUG(0,("monitor event OK - node re-enabled\n"));
-- ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_DISABLED;
++ ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_UNHEALTHY;
} else {
/* no change */
return;
/* tell the other nodes that something has changed */
ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_VNNMAP,
CTDB_SRVID_NODE_FLAGS_CHANGED, data);
++
}
ctdb_check_health, ctdb);
CTDB_NO_MEMORY_FATAL(ctdb, te);
}
++
++
++/*
++ administratively disable/enable a node
++ */
++int32_t ctdb_control_permdisable(struct ctdb_context *ctdb, TDB_DATA indata)
++{
++ uint32_t set = *(uint32_t *)indata.dptr;
++ TDB_DATA data;
++ struct ctdb_node_flag_change c;
++ struct ctdb_node *node = ctdb->nodes[ctdb->vnn];
++
++ if (set) {
++ node->flags |= NODE_FLAGS_PERMANENTLY_DISABLED;
++ } else {
++ node->flags &= ~NODE_FLAGS_PERMANENTLY_DISABLED;
++ }
++
++ c.vnn = ctdb->vnn;
++ c.flags = node->flags;
++
++ data.dptr = (uint8_t *)&c;
++ data.dsize = sizeof(c);
++
++ /* tell the other nodes that something has changed */
++ ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_VNNMAP,
++ CTDB_SRVID_NODE_FLAGS_CHANGED, data);
++
++ return 0;
++}
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_UNHEALTHY 0x00000002
+ #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004
++#define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
uint32_t flags;
/* used by the dead node monitoring */
void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
++int32_t ctdb_control_permdisable(struct ctdb_context *ctdb, TDB_DATA indata);
++
#endif
}
if(options.machinereadable){
- printf(":Node:IP:Status:\n");
+ printf(":Node:IP:Connected:Disabled:Permanently Disabled:\n");
for(i=0;i<nodemap->num;i++){
- printf(":%d:%s:%d:\n", nodemap->nodes[i].vnn,
+ printf(":%d:%s:%d:%d:%d:\n", nodemap->nodes[i].vnn,
inet_ntoa(nodemap->nodes[i].sin.sin_addr),
- !!nodemap->nodes[i].flags&NODE_FLAGS_CONNECTED);
+ !!(nodemap->nodes[i].flags&NODE_FLAGS_CONNECTED),
- !!(nodemap->nodes[i].flags&NODE_FLAGS_DISABLED),
++ !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY),
+ !!(nodemap->nodes[i].flags&NODE_FLAGS_PERMANENTLY_DISABLED));
}
return 0;
}
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_UNHEALTHY) {
++ flags_str = "UNHEALTHY";
} else if (nodemap->nodes[i].flags & NODE_FLAGS_CONNECTED) {
flags_str = "CONNECTED";
} else {