Bug 1321836

Summary: gluster volume info --xml returns 0 for nonexistent volume
Product: [Community] GlusterFS Reporter: Atin Mukherjee <amukherj>
Component: glusterdAssignee: Samikshan Bairagya <sbairagy>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: low Docs Contact:
Priority: unspecified    
Version: mainlineCC: amukherj, bugs, jholloway, nlevinki, sasundar, sbairagy, vbellur
Target Milestone: ---Keywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: glusterfs-3.9.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1319886
: 1352880 (view as bug list) Environment:
Last Closed: 2017-03-27 18:14:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1319886    
Bug Blocks: 1352880    

Description Atin Mukherjee 2016-03-29 09:01:04 UTC
+++ This bug was initially created as a clone of Bug #1319886 +++

Description of problem:
gluster volume info <nonexistent_volname> --xml and gluster volume status <nonexistent_volname> --xml return 0

Version-Release number of selected component (if applicable):
3.7.5-19 and earlier

How reproducible:
Everytime

Steps to Reproduce:
1. Start glusterd
2. Execute gluster volume info <nonexistent_volume> --xml
     # gluster volume info sdksjsdjl --xml; echo $?
3. Execute gluster volume status <nonexistent_volume> --xml
     # gluster volume info sdksjsdjl --xml; echo $?

Actual results:
Both commands output a return code of 0.
Without --xml, they return 1.

Expected results:
Both commands with nonexistent volume and --xml option should return a non-zero returncode (preferably 1 to match command without --xml)

Additional info:
[root@x ~]# gluster volume info sdksjsdjl --xml; echo $?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr/>
  <volInfo>
    <volumes>
      <count>0</count>
    </volumes>
  </volInfo>
</cliOutput>
0

[root@x ~]# gluster volume status sdksjsdjl --xml; echo $?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>-1</opRet>
  <opErrno>30800</opErrno>
  <opErrstr>Volume sdksjsdjl does not exist</opErrstr>
  <cliOp>volStatus</cliOp>
  <output>Volume sdksjsdjl does not exist</output>
</cliOutput>
0

[root@x ~]# gluster volume info sdksjsdjl; echo $?
Volume sdksjsdjl does not exist
1

[root@x ~]# gluster volume status sdksjsdjl; echo $?
Volume sdksjsdjl does not exist
1

--- Additional comment from Red Hat Bugzilla Rules Engine on 2016-03-21 14:17:23 EDT ---

This bug is automatically being proposed for the current z-stream release of Red Hat Gluster Storage 3 by setting the release flag 'rhgs‑3.1.z' to '?'. 

If this bug should be proposed for a different release, please manually change the proposed release flag.

Comment 1 Vijay Bellur 2016-03-29 11:34:13 UTC
REVIEW: http://review.gluster.org/13843 (Fix opRet value for volume info --xml call on non-existent volume) posted (#1) for review on master by Samikshan Bairagya (samikshan)

Comment 2 Vijay Bellur 2016-06-08 09:48:26 UTC
REVIEW: http://review.gluster.org/13843 (Fix opRet value for volume info --xml call on non-existent volume) posted (#2) for review on master by Samikshan Bairagya (samikshan)

Comment 3 Vijay Bellur 2016-06-17 14:01:28 UTC
REVIEW: http://review.gluster.org/13843 (Fix opRet value for volume info --xml call on non-existent volume) posted (#3) for review on master by Samikshan Bairagya (samikshan)

Comment 4 Vijay Bellur 2016-06-21 07:11:11 UTC
COMMIT: http://review.gluster.org/13843 committed in master by Atin Mukherjee (amukherj) 
------
commit a6e551122c603ab0cba798e7e2b30d3a15191b68
Author: Samikshan Bairagya <samikshan>
Date:   Tue Mar 29 16:24:07 2016 +0530

    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>
    Reviewed-on: http://review.gluster.org/13843
    Smoke: Gluster Build System <jenkins.org>
    CentOS-regression: Gluster Build System <jenkins.org>
    Reviewed-by: darshan n <dnarayan>
    Reviewed-by: Atin Mukherjee <amukherj>
    NetBSD-regression: NetBSD Build System <jenkins.org>

Comment 5 Vijay Bellur 2016-07-05 10:06:26 UTC
REVIEW: http://review.gluster.org/14863 (Fix opRet value for volume info --xml call on non-existent volume) posted (#1) for review on release-3.8 by Samikshan Bairagya (samikshan)

Comment 6 Shyamsundar 2017-03-27 18:14:00 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.9.0, please open a new bug report.

glusterfs-3.9.0 has been announced on the Gluster mailinglists [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://lists.gluster.org/pipermail/gluster-users/2016-November/029281.html
[2] https://www.gluster.org/pipermail/gluster-users/