summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorSamikshan Bairagya <samikshan@gmail.com>2016-03-29 16:24:07 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-06-21 00:11:06 -0700
commita6e551122c603ab0cba798e7e2b30d3a15191b68 (patch)
tree270790caeac909da89ea9753c2048b7efb2c9ae4 /xlators/mgmt
parent4797ca3778d82a671716d4913c14f285591ae959 (diff)
Fix opRet value for volume info --xml call on non-existent volume
The opRet field was being assigned to 0 in the XML output when a gluster volume info --xml call is made on a non-existent volume. This change assigns a value of -1 to opRet for volume info calls for non-existent volumes. Other fields like opErrno and opErrstr are also assigned relevant values Change-Id: I3920c602328f74252c87bb521f5a43d4bdc7d44d BUG: 1321836 Signed-off-by: Samikshan Bairagya <samikshan@gmail.com> Reviewed-on: http://review.gluster.org/13843 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: darshan n <dnarayan@redhat.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index c7ffd818a44..91ae6237c54 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -40,6 +40,7 @@
#include "glusterd-volgen.h"
#include "glusterd-mountbroker.h"
#include "glusterd-messages.h"
+#include "glusterd-errno.h"
#include <sys/resource.h>
#include <inttypes.h>
@@ -1554,7 +1555,6 @@ __glusterd_handle_cli_get_volume (rpcsvc_request_t *req)
GD_MSG_FLAGS_NOTFOUND_IN_DICT, "failed to get flags");
goto out;
}
-
ret = glusterd_get_volumes (req, dict, flags);
out:
@@ -4167,6 +4167,7 @@ int32_t
glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
{
int32_t ret = -1;
+ int32_t ret_bkp = 0;
glusterd_conf_t *priv = NULL;
glusterd_volinfo_t *entry = NULL;
int32_t count = 0;
@@ -4176,7 +4177,6 @@ glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
priv = THIS->private;
GF_ASSERT (priv);
-
volumes = dict_new ();
if (!volumes) {
gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
@@ -4185,10 +4185,11 @@ glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
}
if (cds_list_empty (&priv->volumes)) {
+ if (flags == GF_CLI_GET_VOLUME)
+ ret_bkp = -1;
ret = 0;
goto respond;
}
-
if (flags == GF_CLI_GET_VOLUME_ALL) {
cds_list_for_each_entry (entry, &priv->volumes, vol_list) {
ret = glusterd_add_volume_detail_to_dict (entry,
@@ -4230,12 +4231,15 @@ glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
}
} else if (flags == GF_CLI_GET_VOLUME) {
ret = dict_get_str (dict, "volname", &volname);
+
if (ret)
goto respond;
ret = glusterd_volinfo_find (volname, &entry);
- if (ret)
+ if (ret) {
+ ret_bkp = ret;
goto respond;
+ }
ret = glusterd_add_volume_detail_to_dict (entry,
volumes, count);
@@ -4257,9 +4261,14 @@ respond:
ret = 0;
out:
- rsp.op_ret = ret;
-
- rsp.op_errstr = "";
+ if (ret_bkp == -1) {
+ rsp.op_ret = ret_bkp;
+ rsp.op_errstr = "Volume does not exist";
+ rsp.op_errno = EG_NOVOL;
+ } else {
+ rsp.op_ret = ret;
+ rsp.op_errstr = "";
+ }
glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
(xdrproc_t)xdr_gf_cli_rsp);
ret = 0;