Bug 1144503

Summary: yum-plugin-downloadonly exists with error code 1 on success
Product: Red Hat Enterprise Linux 6 Reporter: Felix Dewaleyne <fdewaley>
Component: yumAssignee: Valentina Mukhamedzhanova <vmukhame>
Status: CLOSED ERRATA QA Contact: Marek Marusic <mmarusic>
Severity: low Docs Contact:
Priority: medium    
Version: 6.6CC: fdewaley, james.antill, ksrot, mmarusic, salmy, tdawson, vmukhame
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: yum-3.2.29-69.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 07:21:26 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: 1075802, 1159926    

Description Felix Dewaleyne 2014-09-19 14:56:24 UTC
Description of problem:
yum-plugin-downloadonly exists with error code 1 on success

Version-Release number of selected component (if applicable):
all versions of yum-plugin-downloadonly 

How reproducible:
all the time

Steps to Reproduce:
1. yum install yum-plugin-downloadonly
2. yum update --downloadonly
3. echo $?

Actual results:
return code 1 with a successful download

Expected results:
return code 0

Additional info:
repeated the test on fedora as yum-plugin-downloadonly has been incorporated into yum in that version - the exit code as of  yum-3.4.3-152.fc20.noarch has been fixed.

Comment 2 Troy Dawson 2014-09-24 15:46:58 UTC
The problem is that the plugin is using PluginYumExit to exit.  PluginYumExit is for exceptions, and thus will always throw a 1 or higher.
If the plugin switches to using sys.exit() it will get a proper exitcode.
Here is what I currently use as a work-around.  You are free to use this if you want.

--- downloadonly.py.original	2014-09-24 09:59:50.272309627 -0500
+++ downloadonly.py	2014-09-24 10:39:36.063628706 -0500
@@ -17,6 +17,7 @@
 # by Menno Smits
 
 from yum.plugins import PluginYumExit, TYPE_INTERACTIVE
+import sys
 
 requires_api_version = '2.1'
 plugin_type = (TYPE_INTERACTIVE,)
@@ -45,4 +46,6 @@
     opts, commands = conduit.getCmdLine()
     # Don't die on errors, or we'll never see them.
     if not conduit.getErrors() and opts.dlonly:
-        raise PluginYumExit('exiting because --downloadonly specified ')
+    	# We have no errors, so exitcode should be 0
+    	conduit.info(2, 'exiting because --downloadonly specified')
+        sys.exit(0)

Comment 3 Troy Dawson 2014-09-24 15:57:55 UTC
Sorry for the tab/spaces error there ... this works better.


--- downloadonly.py.original	2014-09-24 09:59:50.272309627 -0500
+++ downloadonly.py	2014-09-24 10:56:40.915588257 -0500
@@ -17,6 +17,7 @@
 # by Menno Smits
 
 from yum.plugins import PluginYumExit, TYPE_INTERACTIVE
+import sys
 
 requires_api_version = '2.1'
 plugin_type = (TYPE_INTERACTIVE,)
@@ -45,4 +46,6 @@
     opts, commands = conduit.getCmdLine()
     # Don't die on errors, or we'll never see them.
     if not conduit.getErrors() and opts.dlonly:
-        raise PluginYumExit('exiting because --downloadonly specified ')
+        # We have no errors, so exitcode should be 0
+        conduit.info(2, 'exiting because --downloadonly specified')
+        sys.exit(0)

Comment 4 Karel Srot 2014-11-24 19:03:37 UTC
So I guess this is a yum-utils bug then.

Comment 5 Felix Dewaleyne 2014-11-25 09:46:27 UTC
well I don't know, that looks like the updates from Troy fix something in dowloadonly.py to me.

Comment 6 Karel Srot 2014-11-25 10:12:09 UTC
Yep, that would be /usr/lib/yum-plugins/downloadonly.py from yum-plugin-downloadonly which is a yum-utils package.

Comment 23 errata-xmlrpc 2015-07-22 07:21:26 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-1384.html