Bug 1018929 - yum-rhn-plugin syntax issue
yum-rhn-plugin syntax issue
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: yum-rhn-plugin (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Matej Kollar
Pavel Studeník
Depends On:
  Show dependency treegraph
Reported: 2013-10-14 13:44 EDT by Toshio Ernie Kuratomi
Modified: 2015-07-22 03:25 EDT (History)
5 users (show)

See Also:
Fixed In Version: yum-rhn-plugin-0.9.1-54-el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2015-07-22 03:25:08 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to fix rhnplugin for yum (1.08 KB, patch)
2013-10-14 13:44 EDT, Toshio Ernie Kuratomi
no flags Details | Diff

  None (edit)
Description Toshio Ernie Kuratomi 2013-10-14 13:44:08 EDT
Created attachment 812133 [details]
Patch to fix rhnplugin for yum

Description of problem:

The latest version of rhn-client-tools, 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):
Comment 2 Michael Mráka 2013-10-16 04:06:35 EDT
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.

Comment 3 Toshio Ernie Kuratomi 2013-10-16 20:35:55 EDT
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 03:12:30 EDT
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 12:44:25 EDT
Fix looks good to me.
Comment 9 Matej Kollar 2015-03-02 10:18:16 EST
Cherry-picked as

Satellite.git: 9a4b0172f5f12c0aefb65161c425bd5ddb7c5fba
Comment 11 Pavel Studeník 2015-03-12 11:19:18 EDT
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 
   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
  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
  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
  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 11:24:55 EDT
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 03:25:08 EDT
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.


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