summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2014-06-16 17:39:08 +0530
committerVijay Bellur <vbellur@redhat.com>2014-06-16 10:03:12 -0700
commit6e33d855815726bd8ebf1c7cdc3cf233ff7ac231 (patch)
treebee06a88b3e0754af4cbaa055f30fde8600aef4b
parentde22a20a76f5cf0af3ca2898f0bfd8324a191e0c (diff)
glusterd: Fail peer probe/detach commands when peer detach is ongoing
Change-Id: Ifd8099bc235eb395e8fd9ead3197bef71c78042b BUG: 1109812 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/8079 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--rpc/rpc-lib/src/protocol-common.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c44
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h4
4 files changed, 44 insertions, 7 deletions
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index e2b6170b954..1856387826b 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -112,6 +112,7 @@ enum gf_probe_resp {
GF_PROBE_QUORUM_NOT_MET,
GF_PROBE_MISSED_SNAP_CONFLICT,
GF_PROBE_SNAP_CONFLICT,
+ GF_PROBE_FRIEND_DETACHING,
};
enum gf_deprobe_resp {
@@ -121,6 +122,7 @@ enum gf_deprobe_resp {
GF_DEPROBE_BRICK_EXIST,
GF_DEPROBE_FRIEND_DOWN,
GF_DEPROBE_QUORUM_NOT_MET,
+ GF_DEPROBE_FRIEND_DETACHING,
};
enum gf_cbk_procnum {
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 33606461fe2..44666a94d56 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -1042,6 +1042,7 @@ __glusterd_handle_cli_probe (rpcsvc_request_t *req)
dict_t *dict = NULL;
char *hostname = NULL;
int port = 0;
+ int op_errno = 0;
GF_ASSERT (req);
this = THIS;
@@ -1119,12 +1120,17 @@ __glusterd_handle_cli_probe (rpcsvc_request_t *req)
goto out;
}
}
- ret = glusterd_probe_begin (req, hostname, port, dict);
+ ret = glusterd_probe_begin (req, hostname, port, dict, &op_errno);
if (ret == GLUSTERD_CONNECTION_AWAITED) {
//fsm should be run after connection establishes
run_fsm = _gf_false;
ret = 0;
+
+ } else if (ret == -1) {
+ glusterd_xfer_cli_probe_resp (req, -1, op_errno,
+ NULL, hostname, port, dict);
+ goto out;
}
out:
@@ -1254,9 +1260,11 @@ __glusterd_handle_cli_deprobe (rpcsvc_request_t *req)
}
if (!uuid_is_null (uuid)) {
- ret = glusterd_deprobe_begin (req, hostname, port, uuid, dict);
+ ret = glusterd_deprobe_begin (req, hostname, port, uuid, dict,
+ &op_errno);
} else {
- ret = glusterd_deprobe_begin (req, hostname, port, NULL, dict);
+ ret = glusterd_deprobe_begin (req, hostname, port, NULL, dict,
+ &op_errno);
}
out:
@@ -3160,7 +3168,7 @@ out:
int
glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr, int port,
- dict_t *dict)
+ dict_t *dict, int *op_errno)
{
int ret = -1;
glusterd_peerinfo_t *peerinfo = NULL;
@@ -3186,6 +3194,12 @@ glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr, int port,
} else if (peerinfo->connected &&
(GD_FRIEND_STATE_BEFRIENDED == peerinfo->state.state)) {
+ if (peerinfo->detaching) {
+ ret = -1;
+ if (op_errno)
+ *op_errno = GF_PROBE_FRIEND_DETACHING;
+ goto out;
+ }
ret = glusterd_friend_hostname_update (peerinfo, (char*)hoststr,
_gf_false);
if (ret)
@@ -3212,7 +3226,7 @@ out:
int
glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr, int port,
- uuid_t uuid, dict_t *dict)
+ uuid_t uuid, dict_t *dict, int *op_errno)
{
int ret = -1;
glusterd_peerinfo_t *peerinfo = NULL;
@@ -3235,6 +3249,13 @@ glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr, int port,
goto out;
}
+ if (peerinfo->detaching) {
+ ret = -1;
+ if (op_errno)
+ *op_errno = GF_DEPROBE_FRIEND_DETACHING;
+ goto out;
+ }
+
ret = glusterd_friend_sm_new_event
(GD_FRIEND_EVENT_INIT_REMOVE_FRIEND, &event);
@@ -3266,6 +3287,7 @@ glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr, int port,
"ret = %d", event->event, ret);
goto out;
}
+ peerinfo->detaching = _gf_true;
out:
return ret;
@@ -3353,6 +3375,12 @@ set_probe_error_str (int op_ret, int op_errno, char *op_errstr, char *errstr,
" in peer list", hostname, port);
break;
+ case GF_PROBE_FRIEND_DETACHING:
+ snprintf (errstr, len, "Peer is already being "
+ "detached from cluster.\n"
+ "Check peer status by running "
+ "gluster peer status");
+ break;
default:
if (op_errno != 0)
snprintf (errstr, len, "Probe returned "
@@ -3498,6 +3526,12 @@ set_deprobe_error_str (int op_ret, int op_errno, char *op_errstr, char *errstr,
"in this state");
break;
+ case GF_DEPROBE_FRIEND_DETACHING:
+ snprintf (errstr, len, "Peer is already being "
+ "detached from cluster.\n"
+ "Check peer status by running "
+ "gluster peer status");
+ break;
default:
snprintf (errstr, len, "Detach returned with "
"unknown errno %d", op_errno);
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.h b/xlators/mgmt/glusterd/src/glusterd-sm.h
index f903668e9ec..6b3b61dfc5c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.h
@@ -97,6 +97,7 @@ struct glusterd_peerinfo_ {
gf_boolean_t quorum_action;
gd_quorum_contrib_t quorum_contrib;
gf_boolean_t locked;
+ gf_boolean_t detaching;
};
typedef struct glusterd_peerinfo_ glusterd_peerinfo_t;
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 3da22f62f77..b8e8933258a 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -638,7 +638,7 @@ glusterd_brick_from_brickinfo (glusterd_brickinfo_t *brickinfo,
char **new_brick);
int
glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr, int port,
- dict_t *dict);
+ dict_t *dict, int *op_errno);
int
glusterd_xfer_friend_add_resp (rpcsvc_request_t *req, char *myhostname,
@@ -732,7 +732,7 @@ glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname, int por
int
glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr, int port,
- uuid_t uuid, dict_t *dict);
+ uuid_t uuid, dict_t *dict, int *op_errno);
int
glusterd_handle_cli_deprobe (rpcsvc_request_t *req);