Bug 751760

Summary: "AttributeError: CommunicationError instance has no attribute 'value'" when running through stopped proxy
Product: Red Hat Enterprise Linux 5 Reporter: Jan Hutař <jhutar>
Component: rhn-client-toolsAssignee: Miroslav Suchý <msuchy>
Status: CLOSED ERRATA QA Contact: Jiří Mikulka <jmikulka>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 5.7CC: jmikulka, ksrot
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rhn-client-tools-0.4.20-75.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-21 06:30:32 UTC Type: ---
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: 595837, 758797    

Description Jan Hutař 2011-11-07 13:26:21 UTC
Description of problem:
When I'm running through proxy which is stopped, yum fails (which is OK), but it fails with different exception than expected.


Version-Release number of selected component (if applicable):
yum-rhn-plugin-0.5.4-26.el5
yum-3.2.22-38.el5


How reproducible:
always


Steps to Reproduce:
1. Register yourself to RHN (RHN Satellite in my case)
2. Configure yum-rhn-plugin to run through proxy
   # grep -i proxy /etc/sysconfig/rhn/up2date | grep -v comment
   enableProxyAuth=1
   enableProxy=1
   proxyPassword=proxy_password
   proxyUser=proxy_user
   httpProxy=localhost:3128
3. Stop the proxy
   # service squid stop
4. Try to install some package from RHN channel
   # yum install -y test-package


Actual results:
# yum install -y test-regular-mon07nov2011_12_56_42_27745-0.1-1
Loaded plugins: rhnplugin
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in ?
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 309, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 157, in main
    base.getOptionsConfig(args)
  File "/usr/share/yum-cli/cli.py", line 187, in getOptionsConfig
    self.conf
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 665, in <lambda>
    conf = property(fget=lambda self: self._getConfig(),
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 254, in _getConfig
    self.plugins.run('init')
  File "/usr/lib/python2.4/site-packages/yum/plugins.py", line 179, in run
    func(conduitcls(self, self.base, conf, **kwargs))
  File "/usr/lib/yum-plugins/rhnplugin.py", line 148, in init_hook
    conduit.error(0, COMMUNICATION_ERROR + "\n" + CHANNELS_DISABLED + 
  File "/usr/lib/python2.4/site-packages/yum/Errors.py", line 32, in __str__
    return "%s" %(self.value,)
AttributeError: CommunicationError instance has no attribute 'value'


Expected results:
Error message should state there is a problem with connection.


Additional info:
From code inspection this seems to be caused by a mishmash of which variable yum and yum-rhn-plugin are using to store exception string:

=== yum uses self.value in its exceptions ===
# vim /usr/lib/python2.4/site-packages/yum/Errors.py
class YumBaseError(Exception):
    """
    Base Yum Error. All other Errors thrown by yum should inherit from
    this.
    """
    def __init__(self, value=None):
        Exception.__init__(self)
        self.value = value
    def __str__(self):
        return "%s" %(self.value,)

=== yum-rhn-plugin uses self.errmsg ===
# vim /usr/share/rhn/up2date_client/up2dateErrors.py
class Error(YumBaseError):
    """base class for errors"""
    def __init__(self, errmsg):
        self.errmsg = errmsg
        self.log = up2dateLog.initLog()

    def __repr__(self):
        self.log.log_me(self.errmsg)
        return self.errmsg

Comment 1 Miroslav Suchý 2011-11-07 15:25:59 UTC
This is just special case (or better: consequence) of bug 595837.

Fixed in spacewalk.git as commit 1bdc55b83a00d48bb263ba7d4f9c13d3b0ddbb1e

Comment 2 Miroslav Suchý 2011-11-21 20:58:44 UTC
I forgot that backend still use errmsg, so I created setter and getter for errmsg as alias to value.
commited as 61d62a5a31cdfb5094987c2575a5b0a56e9c194d and 369c6fb728bf69c742d1f526244c753b401e0c7a

Comment 3 Miroslav Suchý 2011-11-22 14:50:35 UTC
both commits cherrypicked to svn as rev. 208312.

Comment 6 Miroslav Suchý 2011-11-28 11:46:39 UTC
Fixed in rev. 208328.

Comment 7 Karel Srot 2011-11-28 15:46:39 UTC
*** Bug 756324 has been marked as a duplicate of this bug. ***

Comment 14 errata-xmlrpc 2012-02-21 06:30:32 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.

http://rhn.redhat.com/errata/RHBA-2012-0250.html