Bug 1018929

Summary: yum-rhn-plugin syntax issue
Product: Red Hat Enterprise Linux 6 Reporter: Toshio Ernie Kuratomi <a.badger>
Component: yum-rhn-pluginAssignee: Matej Kollar <mkollar>
Status: CLOSED ERRATA QA Contact: Pavel Studeník <pstudeni>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.6CC: a.badger, cperry, dyordano, kevin, pstudeni
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: yum-rhn-plugin-0.9.1-54-el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 07:25:08 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:
Attachments:
Description Flags
Patch to fix rhnplugin for yum none

Description Toshio Ernie Kuratomi 2013-10-14 17:44:08 UTC
Created attachment 812133 [details]
Patch to fix rhnplugin for yum

Description of problem:

The latest version of rhn-client-tools, 1.0.0.1-8.el6 changed some API.  The API changes break the yum-rhn-plugin.  I'll attach a patch that fixes the API change and also fixes one error that I encountered after that.

Version-Release number of selected component (if applicable):
yum-rhn-plugin-0.9.1-49.el6.noarch

Comment 2 Michael Mráka 2013-10-16 08:06:35 UTC
Hi Toshio,

Could you please post some steps to reproduce the error?
Also what package version do you have installed?
rpm -q rhn-check rhn-client-tools rhn-setup rhn-setup-gnome yum-rhn-plugin rhnlib

It seems to work fine on my test system.

Regards,
Michael

Comment 3 Toshio Ernie Kuratomi 2013-10-17 00:35:55 UTC
Apologies, after further looking into this, the timeout parameter problem is due to an older version of the up2dateAuth.py file from rhn-client-tools that a prior admin had checked into our sytems as a hotfix.  So the timeout problem is bogus.

For the except e: => except Exception, e: change that does address a valid bug in the code.  It only triggers if an exception is actually raised in the try: block, though:

$ python2
>>> try:
...  pass
... except e:
... pass
>>>
>>> try:
...  raise ValueError
... except e:
...  pass
... 
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
NameError: name 'e' is not defined

The token after except needs to be the name of an exception, not a variable to store the exception in.  Since we're trying to catch all exceptions, use "Exception" there to catch any exception.

Comment 4 Michael Mráka 2013-10-17 07:12:30 UTC
Fixed in spacewalk master by
commit 60cf0271cc8a32b709b6f66161938fa03bede4d4
    1018929 - removed redundant exception
    both sections just re-raise exception as RepoError

Comment 6 Toshio Ernie Kuratomi 2013-10-18 16:44:25 UTC
Fix looks good to me.

Comment 9 Matej Kollar 2015-03-02 15:18:16 UTC
Cherry-picked as

Satellite.git: 9a4b0172f5f12c0aefb65161c425bd5ddb7c5fba

Comment 11 Pavel Studeník 2015-03-12 15:19:18 UTC
Reproducer with yum-rhn-plugin-0.9.1-50.el6.noarch

I can't find correctly steps to reproduce. I edit code to get a traceback. 

# vim /usr/share/yum-plugins/rhnplugin.py 
try:
   li = up2dateAuth.getLoginInfo(timeout=self.timeout)
--->
   # create some other traceback: IndexError..
   test = []
   print test[1]
--->
   except up2dateErrors.RhnServerException, e:
      raise yum.Errors.RepoError(unicode(e)), None, sys.exc_info()[2]
   except e:
     raise yum.Errors.RepoError(unicode(e)), None, sys.exc_info()[2]

# yum repolist 

Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 294, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 146, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 438, in doCommands
    return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
  File "/usr/share/yum-cli/yumcommands.py", line 861, in doCommand
    base.repos.populateSack()
  File "/usr/lib/python2.6/site-packages/yum/repos.py", line 319, in populateSack
    sack.populate(repo, mdtype, callback, cacheonly)
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 165, in populate
    if self._check_db_version(repo, mydbtype):
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 223, in _check_db_version
    return repo._check_db_version(mdtype)
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1260, in _check_db_version
    repoXML = self.repoXML
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1459, in <lambda>
    repoXML = property(fget=lambda self: self._getRepoXML(),
  File "/usr/share/yum-plugins/rhnplugin.py", line 567, in _getRepoXML
    return YumRepository._getRepoXML(self)
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1451, in _getRepoXML
    self._loadRepoXML(text=self)
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1441, in _loadRepoXML
    return self._groupLoadRepoXML(text, self._mdpolicy2mdtypes())
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1416, in _groupLoadRepoXML
    if self._commonLoadRepoXML(text):
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1234, in _commonLoadRepoXML
    result = self._getFileRepoXML(local, text)
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1012, in _getFileRepoXML
    size=102400) # setting max size as 100K
  File "/usr/share/yum-plugins/rhnplugin.py", line 389, in _getFile
    start, end, copy_local, checkfunc, text, reget, cache, size)
  File "/usr/share/yum-plugins/rhnplugin.py", line 421, in _noExceptionWrappingGet
    self.setupRhnHttpHeaders()
  File "/usr/share/yum-plugins/rhnplugin.py", line 365, in setupRhnHttpHeaders
    except e:
UnboundLocalError: local variable 'e' referenced before assignment

Comment 12 Pavel Studeník 2015-03-12 15:24:55 UTC
Verified with yum-rhn-plugin-0.9.1-54.el6.noarch

# yum update
Loaded plugins: product-id, rhnplugin, security, subscription-manager
This system is receiving updates from RHN Classic or RHN Satellite.
Setting up Update Process
Error: Cannot retrieve repository metadata (repomd.xml) for repository: rhel-x86_64-server-6. Please verify its path and try again

Comment 13 errata-xmlrpc 2015-07-22 07:25:08 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-1390.html