| Summary: | AttributeError: 'ExtendedHTTPDigestAuth' object has no attribute 'num_401_calls' | ||
|---|---|---|---|
| Product: | Red Hat OpenStack | Reporter: | David Hill <dhill> |
| Component: | python-requests | Assignee: | Lon Hohberger <lhh> |
| Status: | CLOSED NOTABUG | QA Contact: | Shai Revivo <srevivo> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.0 (Kilo) | CC: | apevec, dhill, dmaley, jschluet, lhh, mburns, rhos-maint, srevivo |
| Target Milestone: | --- | Keywords: | ZStream |
| Target Release: | 7.0 (Kilo) | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2017-01-17 13:25: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: | |
This looks like a bug in whatever's calling in to requests. AttributeError: 'ExtendedHTTPDigestAuth' object has no attribute 'num_401_calls' It looks like something's importing requests.auth HTTPDigest to create ExtendedHTTPDigestAuth class but not calling the __init__ function for HTTPDigestAuth, which sets self.num_401_calls to 1. class HTTPDigestAuth(AuthBase):
"""Attaches HTTP Digest Authentication to the given Request object."""
def __init__(self, username, password):
self.username = username
self.password = password
self.last_nonce = ''
self.nonce_count = 0
self.chal = {}
self.pos = None
self.num_401_calls = 1
...
My guess is get_stats.py is creating this derived object and simply needs something like:
class ExtendedHTTPDigestAuth(HTTPDigestAuth):
def __init__(self, username, password ... ):
# ADD THIS LINE
super(ExtendedHTTPDigestAuth, self).__init__(username, password)
# ^^^
This doesn't look like a bug in requests.
|
Description of problem: When trying to connect to a site using FQDN instead of IP, the script will fail with the following trace: CMD = get_stats.py /v1/cluster/stats?interval=5min&stime=2016-01-06T15:21:46Z Traceback (most recent call last): File "get_stats.py", line 36, in <module> resp = requests.get(uri, headers=headers, auth=authDigest) File "/usr/lib/python2.7/site-packages/requests/api.py", line 69, in get return request('get', url, params=params, **kwargs) File "/usr/lib/python2.7/site-packages/requests/api.py", line 50, in request response = session.request(method=method, url=url, **kwargs) File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 465, in request resp = self.send(prep, **send_kwargs) File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 594, in send history = [resp for resp in gen] if allow_redirects else [] File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 196, in resolve_redirects **adapter_kwargs File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 579, in send r = dispatch_hook('response', hooks, r, **kwargs) File "/usr/lib/python2.7/site-packages/requests/hooks.py", line 41, in dispatch_hook _hook_data = hook(hook_data, **kwargs) File "/usr/lib/python2.7/site-packages/requests/auth.py", line 175, in handle_401 self.num_401_calls += 1 AttributeError: 'ExtendedHTTPDigestAuth' object has no attribute 'num_401_calls' The following patch fixes this issue: The scripts are running on a virtual guest. Not on the openstack nodes. The application responded to your questions with the following: Yes, the issue is when using FQDN. >diff -u ofc.auth.py auth.py --- ofc.auth.py 2016-01-05 19:59:29.076607657 +0000 +++ auth.py 2015-11-25 02:35:41.677029892 +0000 @@ -170,6 +170,9 @@ num_401_calls = getattr(self, 'num_401_calls', 1) s_auth = r.headers.get('www-authenticate', '') + #To fix the FQDN issue + self.num_401_calls = 1 + if 'digest' in s_auth.lower() and num_401_calls < 2 self.num_401_calls += 1 Version-Release number of selected component (if applicable): 2.7.0-1 How reproducible: Always Steps to Reproduce: 1. Try to connect to a host using FQDN instead of IP and add authentication over that 2. 3. Actual results: Fails with AttributeError: 'ExtendedHTTPDigestAuth' object has no attribute 'num_401_calls' Expected results: Succeeds Additional info: