Bug 1195446

Summary: python-rhsm sets socket.setdefaulttimeout(60) _always_
Product: Red Hat Enterprise Linux 7 Reporter: Adrian Likins <alikins>
Component: python-rhsmAssignee: candlepin-bugs
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: crog, dgoodwin, stoner
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 11:48:25 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: 1209535    

Description Adrian Likins 2015-02-23 21:03:04 UTC
Description of problem:
See https://github.com/candlepin/subscription-manager/issues/1006 for
upstream report.

python-rhsm always sets socket.defaulttimeout(60), which applies to
any process that imports the module (like yum via subscription-manager plugin). It was meant to only do this for RHEL5 (reluctantly...) where it is the only
option to set socket timeouts (python 2.3) but accidently does it on any python 2.X version (RHEL5/6/7)

in rhsm/connection.py, the line:

   if sys.version_info[0] == 2 and sys.version_info[0] <= 4:
      socket.setdefaulttimeout(60)

should be:

    if sys.version_info[0] == 2 and sys.version_info[1] <= 4:
       socket.setdefaulttimeout(60)


Regardless of version, setting the defaulttimeout is almost certainly wrong,
and should be replaced with per socket timeouts (newer pythons) or other mechanisms to detect timeouts  (event loops and watchdog timers, etc)

Version-Release number of selected component (if applicable):
Since python-rhsm-1.0.4-1

How reproducible:
See upstream bug report, but 'always'.



Expected results:
The default socket timeout to only be changed on RHEL5 and python 2.3, and
probably not even then.


Additional info:

Comment 1 Adrian Likins 2015-02-23 21:05:56 UTC
Original change of default timeout was as fix for
https://bugzilla.redhat.com/show_bug.cgi?id=834108

Comment 2 Adrian Likins 2015-02-23 23:02:04 UTC
pr at https://github.com/candlepin/python-rhsm/pull/144

Comment 3 Chris "Ceiu" Rog 2015-06-22 18:19:09 UTC
Commit: a974e5d636009fa41bec2b4a9d33f853e9e72a2b

Comment 5 John Sefler 2015-07-23 21:10:58 UTC
Demonstrating the failure on RHEL7.1, python-rhsm version...
[root@jsefler-71 ~]# rpm -q python-rhsm python
python-rhsm-1.13.10-1.el7.x86_64
python-2.7.5-16.el7.x86_64
[root@jsefler-71 ~]# cat /usr/local/bin/socketgetdefaulttimeouttest.py
import socket
import yum
yb = yum.YumBase()
print socket.getdefaulttimeout()
yb.getReposFromConfig()
print socket.getdefaulttimeout()
[root@jsefler-71 ~]# python /usr/local/bin/socketgetdefaulttimeouttest.py
None
Loaded plugins: langpacks, product-id
60.0
[root@jsefler-71 ~]# 

^^^^ Notice the value 60.0 



Verifying RHEL7.2, python-rhsm version...
[root@jsefler-72 ~]# rpm -q python-rhsm python
python-rhsm-1.15.3-1.el7.x86_64
python-2.7.5-30.el7.x86_64
[root@jsefler-72 ~]# cat /usr/local/bin/socketgetdefaulttimeouttest.py
import socket
import yum
yb = yum.YumBase()
print socket.getdefaulttimeout()
yb.getReposFromConfig()
print socket.getdefaulttimeout()
[root@jsefler-72 ~]# python /usr/local/bin/socketgetdefaulttimeouttest.py
None
Loaded plugins: langpacks, product-id
None
[root@jsefler-72 ~]# 

^^^^ VERIFIED: the second None value indicates that a default timeout value is no longer being set when run on python 2.7

Comment 6 errata-xmlrpc 2015-11-19 11:48:25 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-2122.html