Bug 912882

Summary: rhn-migrate-classic-to-rhsm fails to connect with xmlrpclib error when going through a proxy.
Product: Red Hat Enterprise Linux 5 Reporter: Alex Wood <awood>
Component: subscription-managerAssignee: Alex Wood <awood>
Status: CLOSED WONTFIX QA Contact: IDM QE LIST <seceng-idm-qe-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.10CC: bkearney, jgalipea, jsefler
Target Milestone: beta   
Target Release: 5.10   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-05-10 15:25:54 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: 840995, 920191    
Attachments:
Description Flags
A fix for this issue none

Description Alex Wood 2013-02-19 22:09:18 UTC
Description of problem:
The xmlrpclib library changed in Python 2.7 and rhn-migrate-classic-to-rhsm no longer works when going through a proxy. 

How reproducible: Always

Steps to Reproduce:
1. Set up RHN to use a proxy.  You need to edit the proxy related values in /etc/sysconfig/rhn/up2date.
2. Register to RHN using rhnreg_ks.
3. Attempt a migration.
  
Actual results:
2013-02-19 16:54:19,512 [INFO]  @migrate.py:340 - Using proxy auto-services.user
sys.redhat.com:3128 for RHN API methods
2013-02-19 16:54:19,537 [ERROR]  @migrate.py:348 - Traceback (most recent call l
ast):
  File "/root/devel/subscription-manager/src/subscription_manager/migrate/migrat
e.py", line 345, in connect_to_rhn
    sk = sc.auth.login(credentials.username, credentials.password)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1294, in single_request
    response = h.getresponse(buffering=True)
AttributeError: HTTP instance has no attribute 'getresponse'

Expected results: A successful migration


Additional info:

Comment 2 Alex Wood 2013-02-20 16:32:40 UTC
This bug is closely related to bug #619276.

To paraphrase David Malcolm in comment 11 of that bug:

The xmlrpclib Transport.request() (in Python 2.7 request() delegates calls to single_request()) method calls make_connection() which returns a connection object (httplib.HTTP prior to 2.7 and httplib.HTTPConnection in 2.7)

Eventually a call is made on the object returned from make_connection().  Python's xmlrpclib has changed from calling getreply() to getresponse() in r73638 [1] [2].

httplib.HTTP does not have a getresponse() method.  It does have a getreply() method (which delegates to an underlying connection instance's getresponse(), with some wrapper logic).

Since we were overriding make_connection() and returning an httplib.HTTP object, we broke when xmlrpclib in 2.7 tried to call getresponse().

The fix is to discriminate between 2.7 and earlier versions.  I have elected to do that by looking for the single_request() method which doesn't exist in pre-2.7.  This technique is the same as the one used by koji in commit 7876bc06 [3].

[1] http://svn.python.org/view?view=rev&revision=73638
[2] http://svn.python.org/view/python/trunk/Lib/xmlrpclib.py?r1=73638&r2=73637&pathrev=73638
[3] http://git.fedorahosted.org/cgit/koji/commit/?id=7876bc06fe9151fb521409c2e8f6a3535e1eacfe

Comment 3 RHEL Program Management 2013-04-09 20:55:17 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux release.  Product Management has
requested further review of this request by Red Hat Engineering, for
potential inclusion in a Red Hat Enterprise Linux release for currently
deployed products.  This request is not yet committed for inclusion in
a release.

Comment 4 Alex Wood 2013-05-10 15:25:54 UTC
This bug should be fixed as a side effect of fixing bug 885130 since we are no longer using xmlrpclib.

Comment 5 Alex Wood 2013-05-10 15:28:32 UTC
Created attachment 746210 [details]
A fix for this issue

A fix for this issue for posterity's sake.