Bug 1202582 - spacecmd returns incorrect return codes in some instances
Summary: spacecmd returns incorrect return codes in some instances
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: spacecmd
Version: 23
Hardware: noarch
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1202684 1428862
TreeView+ depends on / blocked
 
Reported: 2015-03-16 23:40 UTC by PixelDrift.NET Support
Modified: 2017-03-03 14:23 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
: 1202684 (view as bug list)
Environment:
Last Closed: 2016-12-20 13:22:04 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description PixelDrift.NET Support 2015-03-16 23:40:05 UTC
Description of problem:
When spacecmd is used in non-interactive mode, it returns '0' error code in some instances when it should be returning 1 (eg. if the Spacewalk server cannot be contacted).


Version-Release number of selected component (if applicable):

Tested in both the following versions (EPEL and latest nightly rpm build):
spacecmd-1.9.4-1.el6.noarch.rpm
spacecmd-2.3.18-1.el6.noarch.rpm


How reproducible:
100%

Steps to Reproduce:
1. Connect to a invalid host using spacecmd in non-interactive mode (ie. passing a command in quotes)
#spacecmd -s fakehostname.local -u spacewalk -p password "runsomecommand"
ERROR: Failed to connect to https://fakehostname.local/rpc/api

2. Display exit code
#echo $?
0

Actual results:
Exit code '0' is returned.

Expected results:
Exit code '1' should be returned

Additional info:

When running in interactive mode the correct exit code is produced:

#spacecmd -s fakehostname.local -u spacewalk -p password
Welcome to spacecmd, a command-line interface to Spacewalk.

Type: 'help' for a list of commands
      'help <cmd>' for command-specific help
      'quit' to quit

ERROR: Failed to connect to https://fakehostname.local/rpc/api

#echo $?
1

Comment 1 PixelDrift.NET Support 2015-03-17 00:06:03 UTC
It appears the error code _is_ returned correctly in latest release (spacecmd-2.3.18-1.el6.noarch.rpm) apologies.

#spacecmd -s fakehostname.local -u spacewalk -p password "runsomecommand"
ERROR: [Errno -2] Name or service not known

#echo $?
1


But there appears to be some regression in the error handling (error doesn't appear to be caught) when using interactive mode (compare to output in original bug).


#spacecmd -s fakehostname.local -u spacewalk -p password
Welcome to spacecmd, a command-line interface to Spacewalk.

Type: 'help' for a list of commands
      'help <cmd>' for command-specific help
      'quit' to quit

Traceback (most recent call last):
  File "/usr/bin/spacecmd", line 165, in <module>
    if not shell.do_login(''):
  File "/usr/lib/python2.6/site-packages/spacecmd/misc.py", line 298, in do_login
    self.api_version = self.client.api.getVersion()
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1235, in request
    self.send_content(h, request_body)
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1349, in send_content
    connection.endheaders()
  File "/usr/lib64/python2.6/httplib.py", line 908, in endheaders
    self._send_output()
  File "/usr/lib64/python2.6/httplib.py", line 780, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.6/httplib.py", line 739, in send
    self.connect()
  File "/usr/lib64/python2.6/httplib.py", line 1112, in connect
    sock = socket.create_connection((self.host, self.port), self.timeout)
  File "/usr/lib64/python2.6/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known

Comment 2 Jan Kurik 2015-07-15 14:24:03 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 23 development cycle.
Changing version to '23'.

(As we did not run this process for some time, it could affect also pre-Fedora 23 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 23 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora23

Comment 3 Fedora End Of Life 2016-11-24 11:34:14 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 4 Fedora End Of Life 2016-12-20 13:22:04 UTC
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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