1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

add a control to permanently enable/disable a node

(This used to be ctdb commit d66fdba16ca22f62ddac6882a17614879b08a798)
This commit is contained in:
Ronnie Sahlberg 2007-06-07 09:16:17 +10:00
parent 2485d1ef03
commit 9ff733c784
6 changed files with 83 additions and 5 deletions

View 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;
}

View 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;

View 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)) {

View 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

View 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,
};
/*

View 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" },