From 3213a4e013e6f4a67772daa329761f42fea881f0 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Thu, 10 May 2012 16:11:17 +0530 Subject: glusterd,cli: Enable errstr for peer detach This patch adds an op_errstr member to the gf1_cli_deprobe_rsp structure to enable return of an errstr to cli. Change-Id: I0cbb6805b05d7cc0603c13d1c1550bb2bd062a7a BUG: 816840 Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.com/3307 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- cli/src/cli-rpc-ops.c | 64 +++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 28 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 48c1b9718..e54d4d219 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -224,35 +224,43 @@ gf_cli3_1_deprobe_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_INFO, "Received resp to deprobe"); if (rsp.op_ret) { - switch (rsp.op_errno) { - case GF_DEPROBE_LOCALHOST: - snprintf (msg, sizeof (msg), - "%s is localhost", rsp.hostname); - break; - case GF_DEPROBE_NOT_FRIEND: - snprintf (msg, sizeof (msg), - "%s is not part of cluster", - rsp.hostname); - break; - case GF_DEPROBE_BRICK_EXIST: - snprintf (msg, sizeof (msg), - "Brick(s) with the peer %s exist in " - "cluster", rsp.hostname); - break; - case GF_DEPROBE_FRIEND_DOWN: - snprintf (msg, sizeof (msg), - "One of the peers is probably down." - " Check with 'peer status'."); - break; - default: - snprintf (msg, sizeof (msg), - "Detach unsuccessful\nDetach returned" - " with unknown errno %d", - rsp.op_errno); - break; + if (strlen (rsp.op_errstr) > 0) { + snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); + gf_log ("cli", GF_LOG_ERROR, "%s", rsp.op_errstr); + } else { + switch (rsp.op_errno) { + case GF_DEPROBE_LOCALHOST: + snprintf (msg, sizeof (msg), + "%s is localhost", + rsp.hostname); + break; + case GF_DEPROBE_NOT_FRIEND: + snprintf (msg, sizeof (msg), + "%s is not part of cluster", + rsp.hostname); + break; + case GF_DEPROBE_BRICK_EXIST: + snprintf (msg, sizeof (msg), + "Brick(s) with the peer %s " + "exist in cluster", + rsp.hostname); + break; + case GF_DEPROBE_FRIEND_DOWN: + snprintf (msg, sizeof (msg), + "One of the peers is probably" + " down. Check with 'peer " + "status'."); + break; + default: + snprintf (msg, sizeof (msg), + "Detach unsuccessful\nDetach" + " returned with unknown " + "errno %d", rsp.op_errno); + break; + } + gf_log ("cli", GF_LOG_ERROR,"Detach failed with op_ret " + "%d and op_errno %d", rsp.op_ret, rsp.op_errno); } - gf_log ("glusterd",GF_LOG_ERROR,"Detach failed with op_ret %d" - " and op_errno %d", rsp.op_ret, rsp.op_errno); } else { snprintf (msg, sizeof (msg), "Detach successful"); } -- cgit