summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-03-01 03:36:45 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-03-01 15:10:35 -0800
commitae578f0c6518afd22cf13c21eebca203352774d3 (patch)
tree4b0b887f335c0fb0cb83620e0eccd830322fb7cc /cli
parentd95f28de8482c816c2b718d3cf62b667e7a6953c (diff)
gluster rebalance: get the proper/exact error msg to cli
introduce a new field in XDR structure, and hence change the version of program. Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1922 (Volume not present wrong message displayed on command line) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1922
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-rpc-ops.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index c2373e2a5..4e713eef5 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -777,18 +777,18 @@ int
gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_defrag_vol_rsp rsp = {0,};
- cli_local_t *local = NULL;
- char *volname = NULL;
- call_frame_t *frame = NULL;
- int cmd = 0;
- int ret = 0;
+ gf2_cli_defrag_vol_rsp rsp = {0,};
+ cli_local_t *local = NULL;
+ char *volname = NULL;
+ call_frame_t *frame = NULL;
+ int cmd = 0;
+ int ret = 0;
if (-1 == req->rpc_status) {
goto out;
}
- ret = gf_xdr_to_cli_defrag_vol_rsp (*iov, &rsp);
+ ret = gf_xdr_to_cli_defrag_vol_rsp_v2 (*iov, &rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -804,24 +804,34 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
cmd = local->u.defrag_vol.cmd;
}
if (cmd == GF_DEFRAG_CMD_START) {
- cli_out ("starting rebalance on volume %s has been %s", volname,
- (rsp.op_ret) ? "unsuccessful": "successful");
- if (rsp.op_ret && rsp.op_errno == EEXIST)
- cli_out ("Rebalance already started on volume %s",
- volname);
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
+ cli_out (rsp.op_errstr);
+ else
+ cli_out ("starting rebalance on volume %s has been %s",
+ volname, (rsp.op_ret) ? "unsuccessful":
+ "successful");
}
if (cmd == GF_DEFRAG_CMD_STOP) {
- if (rsp.op_ret == -1)
- cli_out ("rebalance volume %s stop failed", volname);
- else
+ if (rsp.op_ret == -1) {
+ if (strcmp (rsp.op_errstr, ""))
+ cli_out (rsp.op_errstr);
+ else
+ cli_out ("rebalance volume %s stop failed",
+ volname);
+ } else {
cli_out ("stopped rebalance process of volume %s \n"
"(after rebalancing %"PRId64" files totaling "
"%"PRId64" bytes)", volname, rsp.files, rsp.size);
+ }
}
if (cmd == GF_DEFRAG_CMD_STATUS) {
- if (rsp.op_ret == -1)
- cli_out ("failed to get the status of rebalance process");
- else {
+ if (rsp.op_ret == -1) {
+ if (strcmp (rsp.op_errstr, ""))
+ cli_out (rsp.op_errstr);
+ else
+ cli_out ("failed to get the status of "
+ "rebalance process");
+ } else {
char *status = "unknown";
if (rsp.op_errno == 0)
status = "not started";
@@ -856,6 +866,10 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
ret = rsp.op_ret;
out:
+ if (rsp.op_errstr)
+ free (rsp.op_errstr); //malloced by xdr
+ if (rsp.volname)
+ free (rsp.volname); //malloced by xdr
cli_cmd_broadcast_response (ret);
return ret;
}