mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
ctdb_daemon: Implement controls DISABLE_NODE/ENABLE_NODE
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14784 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
60c1ef1465
commit
15a6489c28
@ -173,6 +173,40 @@ done:
|
|||||||
TALLOC_FREE(state);
|
TALLOC_FREE(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ctdb_control_disable_node(struct ctdb_context *ctdb)
|
||||||
|
{
|
||||||
|
struct ctdb_node *node;
|
||||||
|
|
||||||
|
node = ctdb_find_node(ctdb, CTDB_CURRENT_NODE);
|
||||||
|
if (node == NULL) {
|
||||||
|
/* Can't happen */
|
||||||
|
DBG_ERR("Unable to find current node\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
D_ERR("Disable node\n");
|
||||||
|
node->flags |= NODE_FLAGS_PERMANENTLY_DISABLED;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ctdb_control_enable_node(struct ctdb_context *ctdb)
|
||||||
|
{
|
||||||
|
struct ctdb_node *node;
|
||||||
|
|
||||||
|
node = ctdb_find_node(ctdb, CTDB_CURRENT_NODE);
|
||||||
|
if (node == NULL) {
|
||||||
|
/* Can't happen */
|
||||||
|
DBG_ERR("Unable to find current node\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
D_ERR("Enable node\n");
|
||||||
|
node->flags &= ~NODE_FLAGS_PERMANENTLY_DISABLED;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
process a control request
|
process a control request
|
||||||
*/
|
*/
|
||||||
@ -827,6 +861,14 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
|||||||
return ctdb_control_echo_data(ctdb, c, indata, async_reply);
|
return ctdb_control_echo_data(ctdb, c, indata, async_reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case CTDB_CONTROL_DISABLE_NODE:
|
||||||
|
CHECK_CONTROL_DATA_SIZE(0);
|
||||||
|
return ctdb_control_disable_node(ctdb);
|
||||||
|
|
||||||
|
case CTDB_CONTROL_ENABLE_NODE:
|
||||||
|
CHECK_CONTROL_DATA_SIZE(0);
|
||||||
|
return ctdb_control_enable_node(ctdb);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
|
DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -3513,6 +3513,52 @@ static void control_check_pid_srvid(TALLOC_CTX *mem_ctx,
|
|||||||
client_send_control(req, header, &reply);
|
client_send_control(req, header, &reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void control_disable_node(TALLOC_CTX *mem_ctx,
|
||||||
|
struct tevent_req *req,
|
||||||
|
struct ctdb_req_header *header,
|
||||||
|
struct ctdb_req_control *request)
|
||||||
|
{
|
||||||
|
struct client_state *state = tevent_req_data(
|
||||||
|
req, struct client_state);
|
||||||
|
struct ctdbd_context *ctdb = state->ctdb;
|
||||||
|
struct ctdb_reply_control reply;
|
||||||
|
|
||||||
|
reply.rdata.opcode = request->opcode;
|
||||||
|
|
||||||
|
DEBUG(DEBUG_INFO, ("Disabling node\n"));
|
||||||
|
ctdb->node_map->node[header->destnode].flags |=
|
||||||
|
NODE_FLAGS_PERMANENTLY_DISABLED;
|
||||||
|
|
||||||
|
reply.status = 0;
|
||||||
|
reply.errmsg = NULL;
|
||||||
|
|
||||||
|
client_send_control(req, header, &reply);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void control_enable_node(TALLOC_CTX *mem_ctx,
|
||||||
|
struct tevent_req *req,
|
||||||
|
struct ctdb_req_header *header,
|
||||||
|
struct ctdb_req_control *request)
|
||||||
|
{
|
||||||
|
struct client_state *state = tevent_req_data(
|
||||||
|
req, struct client_state);
|
||||||
|
struct ctdbd_context *ctdb = state->ctdb;
|
||||||
|
struct ctdb_reply_control reply;
|
||||||
|
|
||||||
|
reply.rdata.opcode = request->opcode;
|
||||||
|
|
||||||
|
DEBUG(DEBUG_INFO, ("Enable node\n"));
|
||||||
|
ctdb->node_map->node[header->destnode].flags &=
|
||||||
|
~NODE_FLAGS_PERMANENTLY_DISABLED;
|
||||||
|
|
||||||
|
reply.status = 0;
|
||||||
|
reply.errmsg = NULL;
|
||||||
|
|
||||||
|
client_send_control(req, header, &reply);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static bool fake_control_failure(TALLOC_CTX *mem_ctx,
|
static bool fake_control_failure(TALLOC_CTX *mem_ctx,
|
||||||
struct tevent_req *req,
|
struct tevent_req *req,
|
||||||
struct ctdb_req_header *header,
|
struct ctdb_req_header *header,
|
||||||
@ -4205,6 +4251,14 @@ static void client_process_control(struct tevent_req *req,
|
|||||||
control_check_pid_srvid(mem_ctx, req, &header, &request);
|
control_check_pid_srvid(mem_ctx, req, &header, &request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CTDB_CONTROL_DISABLE_NODE:
|
||||||
|
control_disable_node(mem_ctx, req, &header, &request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CTDB_CONTROL_ENABLE_NODE:
|
||||||
|
control_enable_node(mem_ctx, req, &header, &request);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (! (request.flags & CTDB_CTRL_FLAG_NOREPLY)) {
|
if (! (request.flags & CTDB_CTRL_FLAG_NOREPLY)) {
|
||||||
control_error(mem_ctx, req, &header, &request);
|
control_error(mem_ctx, req, &header, &request);
|
||||||
|
Loading…
Reference in New Issue
Block a user