From feb99ca3081f838faf9fd9cebfabab8d4c9d015c Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Thu, 3 May 2012 10:43:38 +0530 Subject: glusterd, cli: Enable errstr for peer probe Presently glusterd only returns an errno to cli for peer probe command. This patch allows glusterd to return an errstr as well to cli. An op_errstr member has been added to gf1_cli_probe_rsp and gd1_mgmt_probe_rsp structs to allow this. In case of an error, cli will display the errstr if it was set. If errstr is not set cli will display the error message based on errno. Also, to allow for return of errstr in cases such as handshake failure, an errstr member has been added to the glusterd_peerctx_t struct. Change-Id: Iece2b44a7181555e960d9fe4517ec6cda4cdb385 BUG: 816840 Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.com/3262 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- cli/src/cli-rpc-ops.c | 75 ++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'cli/src/cli-rpc-ops.c') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 434e9a6b13c..48c1b971820 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -136,41 +136,48 @@ gf_cli3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, } if (rsp.op_ret) { - switch (rsp.op_errno) { - case GF_PROBE_ANOTHER_CLUSTER: - snprintf (msg, sizeof (msg), - "%s is already part of another" - " cluster", rsp.hostname); - break; - case GF_PROBE_VOLUME_CONFLICT: - snprintf (msg, sizeof (msg), - "Atleast one volume on %s conflicts " - "with existing volumes in the " - "cluster", rsp.hostname); - break; - case GF_PROBE_UNKNOWN_PEER: - snprintf (msg, sizeof (msg), - "%s responded with 'unknown peer'" - " error, this could happen if %s " - "doesn't have localhost in its peer" - " database", rsp.hostname, - rsp.hostname); - break; - case GF_PROBE_ADD_FAILED: - snprintf (msg, sizeof (msg), - "Failed to add peer information " - "on %s" , rsp.hostname); - break; - - default: - snprintf (msg, sizeof (msg), - "Probe unsuccessful\nProbe returned " - "with unknown errno %d", - rsp.op_errno); - break; + if (rsp.op_errstr && (strlen (rsp.op_errstr) > 0)) { + snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); + } else { + switch (rsp.op_errno) { + case GF_PROBE_ANOTHER_CLUSTER: + snprintf (msg, sizeof (msg), + "%s is already part of " + "another cluster", + rsp.hostname); + break; + case GF_PROBE_VOLUME_CONFLICT: + snprintf (msg, sizeof (msg), + "Atleast one volume on %s " + "conflicts with existing " + "volumes in the cluster", + rsp.hostname); + break; + case GF_PROBE_UNKNOWN_PEER: + snprintf (msg, sizeof (msg), + "%s responded with 'unknown " + "peer' error, this could " + "happen if %s doesn't have " + "localhost in its peer " + "database", rsp.hostname, + rsp.hostname); + break; + case GF_PROBE_ADD_FAILED: + snprintf (msg, sizeof (msg), + "Failed to add peer " + "information on %s" , + rsp.hostname); + break; + + default: + snprintf (msg, sizeof (msg), + "Probe unsuccessful\nProbe " + "returned with unknown errno " + "%d", rsp.op_errno); + break; + } } - gf_log ("glusterd",GF_LOG_ERROR,"Probe failed with op_ret %d" - " and op_errno %d", rsp.op_ret, rsp.op_errno); + gf_log ("cli", GF_LOG_ERROR, "%s", msg); } #if (HAVE_LIB_XML) -- cgit