Bug 1785666

Summary: TypeError("unsupported operand type(s) for -=: 'Retry' and 'int'",)
Product: Red Hat Enterprise Linux 7 Reporter: Martin Bašti <mbasti>
Component: python-requestsAssignee: Charalampos Stratakis <cstratak>
Status: CLOSED ERRATA QA Contact: RHEL CS Apps Subsystem QE <rhel-cs-apps-subsystem-qe>
Severity: medium Docs Contact:
Priority: high    
Version: 7.5CC: cstratak, daviddavis, external.z17jmagn, gscarbor, hhorak, janarula, jhouska, julian.taylor, ktordeur, momran, pviktori, python-maint, sgraf, slutade, swadeley, twaugh, wchadwic
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 1811055 1811056 1811057 1811058 (view as bug list) Environment:
Last Closed: 2020-09-29 19:39:41 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: 1811055, 1811056, 1811057, 1811058    

Description Martin Bašti 2019-12-20 15:55:57 UTC
Description of problem:

We are hitting following issue after installing python-requests-2.6.0-5.el7_5.noarch

Original traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/osbs/http.py", line 59, in request
    stream = HttpStream(url, *args, verbose=self.verbose, **kwargs)
  File "/usr/lib/python2.7/site-packages/osbs/http.py", line 156, in __init__
    self.req = self.session.request(method, url, **args)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 464, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 370, in send
    timeout=timeout
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 597, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python2.7/site-packages/urllib3/util/retry.py", line 226, in increment
    total -= 1
TypeError("unsupported operand type(s) for -=: 'Retry' and 'int'",)


Replacing
- from requests.packages.urllib3.util import Retry
+ from urllib3.util import Retry
Fixes issue for us


Version-Release number of selected component (if applicable):
python-requests-2.6.0-5.el7_5.noarch

How reproducible:


Steps to Reproduce:
1. Use retry from requests module
2. Force code to retry request
3.

Actual results:
Traceback


Expected results:
Properly retried query

Additional info:
It seems that this was fixed in https://bugzilla.redhat.com/show_bug.cgi?id=1776292 but with python-requests-2.6.0-5.el7_5.noarch we are hitting the same issue. So maybe it was fixed only partially

Comment 9 Petr Viktorin (pviktori) 2020-01-28 14:54:06 UTC
The patch to make `import requests.packages` work is ready. It should solve the the Pulp 2 issue.

Would you be able to test an RPM if we send one to you?

Comment 11 external.z17jmagn 2020-01-28 17:09:27 UTC
Hello,
I have the same error with newer version.

OS Version : CentOS V7.7
python-requests  2.6.0-7.el7_7

Log from /var/log/messages
141360 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976) unsupported operand type(s) for -=: 'Retry' and 'int'
141361 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976) Traceback (most recent call last):
141362 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)   File "/usr/lib/python2.7/site-packages/nectar/downloaders/threaded.py", line 274, in _fetch
141363 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)     **requests_kwargs)
141364 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)   File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 498, in get
141365 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)     return self.request('GET', url, **kwargs)
141366 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)   File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 486, in request
141367 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)     resp = self.send(prep, **send_kwargs)
141368 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)   File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 598, in send
141369 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)     r = adapter.send(request, **kwargs)
141370 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)   File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 370, in send
141371 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)     timeout=timeout
141372 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)   File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 597, in urlopen
141373 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)     _stacktrace=sys.exc_info()[2])
141374 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)   File "/usr/lib/python2.7/site-packages/urllib3/util/retry.py", line 236, in increment
141375 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976)     total -= 1
141376 Jan 28 16:56:29 rtdkh1kat01 pulp: nectar.downloaders.threaded:ERROR: (31721-50976) TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

Comment 12 external.z17jmagn 2020-01-28 17:12:07 UTC
Error about python-requests :

Tested version :  python-requests  2.6.0-8.el7.7

Comment 14 external.z17jmagn 2020-01-30 10:54:07 UTC
Hello All,
I have continued my testing and found a workaround.

python-requests 2.6.0-8.el7.7           Error
python-requests 2.6.0-7.el7.7           It works fine

Pulp operation run without error

Comment 30 Jan Houska 2020-05-24 19:57:03 UTC
VERIFIED:
all modules from comment 23 was successfully  loaded. 


version:
python-requests-2.6.0-10.el7.noarch

Comment 34 errata-xmlrpc 2020-09-29 19:39:41 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 (python-requests bug fix and enhancement update), 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://access.redhat.com/errata/RHBA-2020:3886