diff options
author | Tim Burke <tim.burke@gmail.com> | 2018-01-25 17:34:39 -0800 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2018-04-10 15:49:03 -0700 |
commit | e503fbd9412d94be43962af3b3ef7067d7f7f49b (patch) | |
tree | b14f56bffecd095c03d847cd1574d6dc948848a7 /keystonemiddleware/auth_token | |
parent | a742c2a77aa6fadbce5e1f9ecb897010dc9df40e (diff) | |
download | keystonemiddleware-e503fbd9412d94be43962af3b3ef7067d7f7f49b.tar.gz |
Only include response body if there's a response
When handling timeouts talking to the keystone server, you may see log
messages like
authtoken: Bad response code while validating token: 408
authtoken: Token validation failure.
<traceback>
AttributeError: 'NoneType' object has no attribute 'text'
Since there's no response from the server when keystoneclient raises
RequestTimeout [1], the `response` attribute is understandably None.
Now, only log the response text if there's text to log. Additionally,
log the response message (as well as status code) to provide as much
context as we can for the error.
[1] https://github.com/openstack/python-keystoneclient/blob/3.15.0/keystoneclient/session.py#L469
Change-Id: Id400e4c38d07cbe7e1866dd572a17fc54c31e82a
Diffstat (limited to 'keystonemiddleware/auth_token')
-rw-r--r-- | keystonemiddleware/auth_token/_identity.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/keystonemiddleware/auth_token/_identity.py b/keystonemiddleware/auth_token/_identity.py index b7f2eff..c07eb45 100644 --- a/keystonemiddleware/auth_token/_identity.py +++ b/keystonemiddleware/auth_token/_identity.py @@ -234,9 +234,10 @@ class IdentityServer(object): raise ksm_exceptions.ServiceError(msg) except ksa_exceptions.HttpError as e: self._LOG.error( - 'Bad response code while validating token: %s', - e.http_status) - self._LOG.warning('Identity response: %s', e.response.text) + 'Bad response code while validating token: %s %s', + e.http_status, e.message) + if hasattr(e.response, 'text'): + self._LOG.warning('Identity response: %s', e.response.text) msg = _('Failed to fetch token data from identity server') raise ksm_exceptions.ServiceError(msg) else: |