summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushal M <kaushal@gluster.com>2011-09-14 18:29:18 +0530
committerVijay Bellur <vijay@gluster.com>2011-10-01 05:54:42 -0700
commitacea7409a35d03c438ff2738f701add26f0061c9 (patch)
treeb9a46fcf984a97f55b706f2373dcfdad12f5e81c
parent795c8996c18f5e8ef5986581644374d0c5068772 (diff)
glusterd, cli: adds 'force' for 'peer detach'
Adds add a 'force' option to 'peer detach' to forcefully detach a peer from a cluster, even when the cluster contains volumes with bricks on the peer. Change-Id: I134df51c16a07345c8869b318141d427b572eba5 BUG: 3549 Reviewed-on: http://review.gluster.com/429 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
-rw-r--r--cli/src/cli-cmd-peer.c20
-rw-r--r--cli/src/cli-rpc-ops.c7
-rw-r--r--rpc/xdr/src/cli1-xdr.c2
-rw-r--r--rpc/xdr/src/cli1-xdr.h1
-rw-r--r--rpc/xdr/src/cli1-xdr.x1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c7
6 files changed, 32 insertions, 6 deletions
diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c
index 3b41195a1bb..cad520dfcb5 100644
--- a/cli/src/cli-cmd-peer.c
+++ b/cli/src/cli-cmd-peer.c
@@ -31,6 +31,7 @@
#include "cli.h"
#include "cli-cmd.h"
#include "cli-mem-types.h"
+#include "cli1-xdr.h"
#include "protocol-common.h"
extern struct rpc_clnt *global_rpc;
@@ -107,10 +108,11 @@ cli_cmd_peer_deprobe_cbk (struct cli_state *state, struct cli_cmd_word *word,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *dict = NULL;
+ int flags = 0;
int sent = 0;
int parse_error = 0;
- if (!(wordcount == 3) ) {
+ if ((wordcount < 3) || (wordcount > 4)) {
cli_usage_out (word->pattern);
parse_error = 1;
goto out;
@@ -134,6 +136,20 @@ cli_cmd_peer_deprobe_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
*/
+ if (wordcount == 4) {
+ if (!strcmp("force", words[3]))
+ flags |= GF_CLI_FLAG_OP_FORCE;
+ else {
+ ret = -1;
+ cli_usage_out (word->pattern);
+ parse_error = 1;
+ goto out;
+ }
+ }
+ ret = dict_set_int32 (dict, "flags", flags);
+ if (ret)
+ goto out;
+
if (proc->fn) {
ret = proc->fn (frame, THIS, dict);
}
@@ -188,7 +204,7 @@ struct cli_cmd cli_probe_cmds[] = {
cli_cmd_peer_probe_cbk,
"probe peer specified by <HOSTNAME>"},
- { "peer detach <HOSTNAME>",
+ { "peer detach <HOSTNAME> [force]",
cli_cmd_peer_deprobe_cbk,
"detach peer specified by <HOSTNAME>"},
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 1e77ae0ab71..f8662ea5528 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -1718,6 +1718,7 @@ gf_cli3_1_deprobe (call_frame_t *frame, xlator_t *this,
dict_t *dict = NULL;
char *hostname = NULL;
int port = 0;
+ int flags = 0;
if (!frame || !this || !data) {
ret = -1;
@@ -1733,9 +1734,13 @@ gf_cli3_1_deprobe (call_frame_t *frame, xlator_t *this,
if (ret)
port = CLI_GLUSTERD_PORT;
+ ret = dict_get_int32 (dict, "flags", &flags);
+ if (ret)
+ flags = 0;
+
req.hostname = hostname;
req.port = port;
-
+ req.flags = flags;
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_DEPROBE, NULL,
this, gf_cli3_1_deprobe_cbk,
diff --git a/rpc/xdr/src/cli1-xdr.c b/rpc/xdr/src/cli1-xdr.c
index 5885000cd8a..d325ac42ae2 100644
--- a/rpc/xdr/src/cli1-xdr.c
+++ b/rpc/xdr/src/cli1-xdr.c
@@ -255,6 +255,8 @@ xdr_gf1_cli_deprobe_req (XDR *xdrs, gf1_cli_deprobe_req *objp)
return FALSE;
if (!xdr_int (xdrs, &objp->port))
return FALSE;
+ if (!xdr_int (xdrs, &objp->flags))
+ return FALSE;
return TRUE;
}
diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h
index 32f624faf60..b92c707bb4d 100644
--- a/rpc/xdr/src/cli1-xdr.h
+++ b/rpc/xdr/src/cli1-xdr.h
@@ -176,6 +176,7 @@ typedef struct gf1_cli_probe_rsp gf1_cli_probe_rsp;
struct gf1_cli_deprobe_req {
char *hostname;
int port;
+ int flags;
};
typedef struct gf1_cli_deprobe_req gf1_cli_deprobe_req;
diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x
index 5ff7aa3e98a..146ed68d35a 100644
--- a/rpc/xdr/src/cli1-xdr.x
+++ b/rpc/xdr/src/cli1-xdr.x
@@ -117,6 +117,7 @@ enum gf1_cli_top_op {
struct gf1_cli_deprobe_req {
string hostname<>;
int port;
+ int flags;
} ;
struct gf1_cli_deprobe_rsp {
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 4e4b73bf493..497813065a2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -693,7 +693,7 @@ int
glusterd_handle_cli_deprobe (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_probe_req cli_req = {0,};
+ gf1_cli_deprobe_req cli_req = {0,};
uuid_t uuid = {0};
int op_errno = 0;
xlator_t *this = NULL;
@@ -705,7 +705,8 @@ glusterd_handle_cli_deprobe (rpcsvc_request_t *req)
GF_ASSERT (priv);
GF_ASSERT (req);
- if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_probe_req)) {
+ if (!xdr_to_generic (req->msg[0], &cli_req,
+ (xdrproc_t)xdr_gf1_cli_deprobe_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
@@ -725,7 +726,7 @@ glusterd_handle_cli_deprobe (rpcsvc_request_t *req)
goto out;
}
- if (!uuid_is_null (uuid)) {
+ if (!uuid_is_null (uuid) && !(cli_req.flags & GF_CLI_FLAG_OP_FORCE)) {
ret = glusterd_all_volume_cond_check (
glusterd_friend_brick_belongs,
-1, &uuid);