Bug 635628 - wrong return code of wallaby utility
wrong return code of wallaby utility
Status: CLOSED ERRATA
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: wallaby-utils (Show other bugs)
1.3
All Linux
low Severity medium
: 1.3.2
: ---
Assigned To: Will Benton
Lubos Trilety
:
Depends On:
Blocks: 668432 668797 668798 668799 668800 668802 668803
  Show dependency treegraph
 
Reported: 2010-09-20 07:08 EDT by Lubos Trilety
Modified: 2011-02-15 07:17 EST (History)
3 users (show)

See Also:
Fixed In Version: wallaby-0.10.4-2
Doc Type: Bug Fix
Doc Text:
In certain cases, error conditions could cause the 'wallaby' shell to exit with a status code 0 (which normally indicates a successful end of an operation) even though the operation did not complete successfully. As a result of general improvements to the 'wallaby' shell, in any error cases, the 'wallaby' shell exits with an appropriate (non-zero) status code.
Story Points: ---
Clone Of:
: 668797 668798 668799 668800 668802 668803 (view as bug list)
Environment:
Last Closed: 2011-02-15 07:17:10 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Lubos Trilety 2010-09-20 07:08:58 EDT
Description of problem:
In some cases when there is bad input used wallaby utility returns wrong code (0)
E.g.
'wallaby -arg'
'wallaby make-snapshot'
'wallaby dump -arg'
...

Version-Release number of selected component (if applicable):
wallaby-utils-0.9.18-2

How reproducible:
100%

Steps to Reproduce:
1. run wallaby utility with wrong option 'wallaby -arg'
2. see return code 'echo $?'
  
Actual results:
wallaby utility returns 0

Expected results:
wallaby should return other number than 0

Additional info:
Comment 1 Will Benton 2010-10-20 10:58:01 EDT
Fixed in master; packaged in the next version post-0.9.22.
Comment 2 Will Benton 2010-11-24 10:27:52 EST
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
C: Some error conditions may cause the wallaby shell to exit with a 0 status.
C: This is confusing, since 0 exit statuses typically indicate success.
F:  These cases are handled generally as a result of internal improvements to the wallaby shell.
R:  The wallaby shell will now exit with an appropriate (nonzero) exit status in error cases.
Comment 4 Petr Matousek 2011-01-10 09:20:04 EST
The Behaviour was fixed for the listed commands, but there are still lot of cases with incorrect return value. The issue should be solved more in general.

below are listed some examples:

1.) wallaby make-snapshot command was changed to raise an error message and return non-zero error code when no argument is supplied. The behaviour should be unified for all commands requiring an argument:

# correct 
[root@rhel5.5-i686 ~]# wallaby make-snapshot
fatal:  you must specify exactly one snapshot name
[root@rhel5.5-i686 ~]# echo $?
1

# incorrect
[root@rhel5.5-x86_64 ~]# wallaby add-feature
[root@rhel5.5-x86_64 ~]# echo $?
0
[root@rhel5.5-x86_64 ~]# wallaby  add-node
[root@rhel5.5-x86_64 ~]# echo $?
0
...

2.) Listing wallaby snapshot should end with success even if there are no snapshots

[root@rhel5.5-i686 ~]# wallaby list-snapshots
Console Connection Established...
[root@rhel5.5-i686 ~]# echo $?
1

3.) Getting help for command should end with success:

[root@rhel5.5-x86_64 ~]# wallaby help load 
Usage:  wallaby load SNAPFILE
Loads a wallaby snapshot from SNAPFILE..
    -h, --help                       displays this message
    -a, --activate                   attempt to activate config after loading
    -q, --quiet                      do not provide progress on load feedback
    -v, --verbose                    provide more progress on load feedback
[root@rhel5.5-x86_64 ~]# echo $?
1

4.) Showing, modifying and removing not existing features or params should exit with non-zero exit code  

[root@rhel5.5-i686 ~]# wallaby modify-feature nonexist
Modifying the following feature: nonexist with {}
Console Connection Established...
warning:  couldn't find feature nonexist
[root@rhel5.5-i686 ~]# echo $?
0

[root@rhel5.5-i686 ~]# wallaby show-param nonexist
Console Connection Established...
warning:  couldn't find param nonexist
[root@rhel5.5-i686 ~]# echo $?
0

[root@rhel5.5-i686 ~]# wallaby remove-param nonexist
Removing the following param: nonexist
Console Connection Established...
[root@rhel5.5-i686 ~]# echo $?
0

5.) Explaining not existing node should exit with non-zero exit code.

[root@rhel5.5-i686 ~]# wallaby explain nonexist
Console Connection Established...
### Explaining the configuration for notexist
# WALLABY_CONFIG_VERSION is set automatically
WALLABY_CONFIG_VERSION = 0
[root@rhel5.5-i686 ~]# echo $?
0

6.) Displaying not existing node should exit with non-zero exit code, moreover error message should appear and no nodes should not be displayed.

show node :
[root@rhel5.5-i686 ~]# wallaby show-node nonexist
Console Connection Established...
notexist
  name:  "notexist"
  provisioned:  false
  last_checkin:  0
  last_updated_version:  0
  memberships:  []
[root@rhel5.5-i686 ~]# echo $?
0

Should I raise separate bugzilla for the issue no.6?

Version-Release number of selected component:
wallaby-utils-0.10.0-2.el5

ASSIGNED
Comment 5 Will Benton 2011-01-10 10:37:52 EST
Issue number 6 is due to the show-node command using the getNode API call, which creates a node if it doesn't exist.  Nice catch!
Comment 6 Will Benton 2011-01-11 11:55:33 EST
I've marked this MODI again and have split the new issues Petr raised off into separate bugs cloned from this one.
Comment 8 Lubos Trilety 2011-01-28 08:13:22 EST
Version:
wallaby-0.10.4-2

There are still some commands which ends with incorrect code: 

1.) Following command shouldn't print invalid option and should end with success - 0
# wallaby feature-import --help
invalid option: --help
Usage:  wallaby feature-import [options] FILE
Imports a wallaby feature from a specially-formatted configuration file.
    -h, --help                       displays this message
    -n, --name NAME                  name for given feature (overrides one specified in the file)
# echo $?
1

2.) Wallaby command with invalid argument should exit with non-zero code
# wallaby -arg
invalid argument: -arg
Usage:  wallaby [options] command [command-args]
Use "wallaby help commands" for a list of commands
    -h, --help                       shows this message
    -H, --host HOSTNAME              qpid broker host (default localhost)
    -p, --port NUM                   qpid broker port (default 5672)
    -U, --user NAME                  qpid username
    -P, --password PASS              qpid password
    -M, --auth-mechanism PASS        authentication mechanism (ANONYMOUS, PLAIN, GSSAPI)
# echo $?
0

>>> ASSIGNED
Comment 9 Matthew Farrellee 2011-01-28 09:40:20 EST
Comment 8 is now bug 673520
Comment 10 Lubos Trilety 2011-01-28 10:59:51 EST
Except from comment 8, which will be corrected later (new bug 673520 was created for that), it seems OK.

Tested with (version):
wallaby-0.10.4-2

Tested on:
RHEL5 i386,x86_64  - passed

>>> VERIFIED
Comment 11 Martin Prpic 2011-02-08 11:31:01 EST
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,4 +1 @@
-C: Some error conditions may cause the wallaby shell to exit with a 0 status.
+In certain cases, error conditions could cause the 'wallaby' shell to exit with a status code 0 (which normally indicates a successful end of an operation) even though the operation did not complete successfully. As a result of general improvements to the 'wallaby' shell, in any error cases, the 'wallaby' shell exits with an appropriate (non-zero) status code.-C: This is confusing, since 0 exit statuses typically indicate success.
-F:  These cases are handled generally as a result of internal improvements to the wallaby shell.
-R:  The wallaby shell will now exit with an appropriate (nonzero) exit status in error cases.
Comment 12 errata-xmlrpc 2011-02-15 07:17:10 EST
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0217.html

Note You need to log in before you can comment on or make changes to this bug.