This patch supports killing one node in the sheepdog cluster. Usage: $ shepherd debug -o kill [hostname] Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp> --- collie/net.c | 5 +++++ include/sheepdog_proto.h | 1 + shepherd/shepherd.c | 13 ++++++++++++- 3 files changed, 18 insertions(+), 1 deletions(-) diff --git a/collie/net.c b/collie/net.c index 09b2452..4428ee1 100644 --- a/collie/net.c +++ b/collie/net.c @@ -40,6 +40,11 @@ static void queue_request(struct request *req) struct sd_req *hdr = (struct sd_req *)&req->rq; struct sd_rsp *rsp = (struct sd_rsp *)&req->rp;; + if (hdr->opcode == SD_OP_DEBUG_KILL) { + log_close(); + exit(1); + } + if (sys->status == SD_STATUS_SHUTDOWN) { rsp->result = SD_RES_SHUTDOWN; req->done(req); diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h index a41eb50..f124286 100644 --- a/include/sheepdog_proto.h +++ b/include/sheepdog_proto.h @@ -38,6 +38,7 @@ #define SD_OP_DEBUG_INC_NVER 0xA0 #define SD_OP_DEBUG_SET_NODE 0xA1 +#define SD_OP_DEBUG_KILL 0xA2 #define SD_OP_CREATE_AND_WRITE_OBJ 0x01 #define SD_OP_REMOVE_OBJ 0x02 diff --git a/shepherd/shepherd.c b/shepherd/shepherd.c index 55a4fe0..1949f13 100644 --- a/shepherd/shepherd.c +++ b/shepherd/shepherd.c @@ -275,6 +275,8 @@ static int debug(char *op, char *arg) if (!op) return 1; + strcpy(name, "localhost"); + if (!strcasecmp(op, "node_version")) { rlen = 0; wlen = 0; @@ -315,10 +317,19 @@ static int debug(char *op, char *arg) opcode = SD_OP_GET_EPOCH; flags = 0; } + } else if (!strcasecmp(op, "kill")) { + if (!arg) { + fprintf(stderr, "specify hostname\n"); + return 1; + } + strcpy(name, arg); + rlen = 0; + wlen = 0; + opcode = SD_OP_DEBUG_KILL; + flags = 0; } else return 1; - strcpy(name, "localhost"); fd = connect_to(name, sdport); if (fd < 0) return -1; -- 1.5.6.5 |