Bug 1162160

Summary: when you give incorrect OrgID to spacewalk-export, it happily continues and exits with 0
Product: Red Hat Satellite 5 Reporter: Jan Hutař <jhutar>
Component: OtherAssignee: Grant Gainey <ggainey>
Status: CLOSED ERRATA QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: low Docs Contact:
Priority: low    
Version: 570CC: cperry, ggainey, lhellebr, mbridon, mkollar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-utils-2.3.2-15 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-04-23 13:20:07 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:    
Bug Blocks: 1162131    

Description Jan Hutař 2014-11-10 12:08:57 UTC
Description of problem:
When you give incorrect OrgID to spacewalk-export, it happily continues.


Version-Release number of selected component (if applicable):
spacewalk-utils-2.3.2-8.el6sat.noarch


How reproducible:
always


Steps to Reproduce:
1. # spacewalk-export --org=11111111111111111111111111111


Actual results:
# rpm -qf `type -p spacewalk-export`
spacewalk-utils-2.3.2-8.el6sat.noarch
# spacewalk-export --org=11111111111111111111111111111
INFO: Processing users...
INFO: Processing system-groups...
INFO: Processing config-files...
INFO: Processing repositories...
INFO: Processing channels...
Traceback (most recent call last):
  File "/usr/bin/spacewalk-export-channels", line 299, in <module>
    export_packages(options)
  File "/usr/bin/spacewalk-export-channels", line 97, in export_packages
    for org in orgs:
TypeError: 'NoneType' object is not iterable
INFO: Processing activation-keys...
INFO: Processing kickstart-scripts...
INFO: Processing system-profiles...
INFO: Export-file created at /root/spacewalk-export-dir/spacewalk_export.tar.gz
# echo $?
0


Expected results:
There is a traceback in the output, but that is all.
Tool should fail and exit with non-0 return code.

Comment 1 RHEL Program Management 2014-11-10 12:33:16 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Grant Gainey 2015-01-27 18:50:50 UTC
SW commit 81a2d535c4271ee384875311758a611946ba7048

Comment 5 Grant Gainey 2015-02-06 19:14:20 UTC
Fixed behavior is:

* spacewalk-export-channels now works even if no-orgs-with-id are found
* spacewalk-export now checks for error-returns and logs ERROR when it finds them

Comment 8 Lukáš Hellebrandt 2015-02-11 16:23:42 UTC
Verified with spacewalk-utils-2.3.2-15

1) Export works with a correct org id.
2) After specifying an incorrect org id, the resulting archive is empty and no traceback is shown. Returns 0.
3) Errors are propagated and printed correctly (tested artificially with sys.exit(1) ). Return code is still 0 on failure but that's OK according to devel - the whole tool should only return non-zero on critical errors.

Result of 3):

INFO: Processing users...
INFO: Processing system-groups...
INFO: Processing config-files...
INFO: Processing repositories...
INFO: Processing channels...
ERROR: Error response from /usr/bin/spacewalk-export-channels : [1]
INFO: Processing activation-keys...
INFO: Processing kickstart-scripts...
INFO: Processing system-profiles...
INFO: Export-file created at /root/spacewalk-export-dir/spacewalk_export.tar.gz

echo $?
0

Comment 10 Mathieu Bridon 2015-04-23 13:20:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0281.html