summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-02-20 19:13:07 +0000
committerGerrit Code Review <review@openstack.org>2018-02-20 19:13:08 +0000
commit2a6a905949cd456667eaec6fb1cf5f09d03a97e2 (patch)
tree3de17196e376678104879579bbcff9ccadae374f
parent499979df5f33315259e74a2d38491b2d4a6282cd (diff)
parentd3352ff422db6ba6a5e7bd4f7220af0d97efd0ac (diff)
Merge "Identify the keystone service when raising 503"HEADmaster
-rw-r--r--keystonemiddleware/auth_token/__init__.py3
-rw-r--r--keystonemiddleware/tests/unit/auth_token/base.py6
-rw-r--r--keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py4
-rw-r--r--releasenotes/notes/bug-1747655-6e563d9317bb0f13.yaml9
4 files changed, 19 insertions, 3 deletions
diff --git a/keystonemiddleware/auth_token/__init__.py b/keystonemiddleware/auth_token/__init__.py
index 6766818..48140b0 100644
--- a/keystonemiddleware/auth_token/__init__.py
+++ b/keystonemiddleware/auth_token/__init__.py
@@ -778,7 +778,8 @@ class AuthProtocol(BaseAuthProtocol):
778 ksm_exceptions.RevocationListError, 778 ksm_exceptions.RevocationListError,
779 ksm_exceptions.ServiceError) as e: 779 ksm_exceptions.ServiceError) as e:
780 self.log.critical('Unable to validate token: %s', e) 780 self.log.critical('Unable to validate token: %s', e)
781 raise webob.exc.HTTPServiceUnavailable() 781 raise webob.exc.HTTPServiceUnavailable(
782 'The Keystone service is temporarily unavailable.')
782 except ksm_exceptions.InvalidToken: 783 except ksm_exceptions.InvalidToken:
783 self.log.debug('Token validation failure.', exc_info=True) 784 self.log.debug('Token validation failure.', exc_info=True)
784 if token_hashes: 785 if token_hashes:
diff --git a/keystonemiddleware/tests/unit/auth_token/base.py b/keystonemiddleware/tests/unit/auth_token/base.py
index 775ddc3..23b8673 100644
--- a/keystonemiddleware/tests/unit/auth_token/base.py
+++ b/keystonemiddleware/tests/unit/auth_token/base.py
@@ -15,6 +15,7 @@ from oslo_config import cfg
15from oslo_config import fixture as cfg_fixture 15from oslo_config import fixture as cfg_fixture
16from oslo_log import log as logging 16from oslo_log import log as logging
17from requests_mock.contrib import fixture as rm_fixture 17from requests_mock.contrib import fixture as rm_fixture
18import six
18from six.moves import http_client 19from six.moves import http_client
19import webob.dec 20import webob.dec
20 21
@@ -48,7 +49,8 @@ class BaseAuthTokenTestCase(utils.MiddlewareTestCase):
48 return auth_token.AuthProtocol(_do_cb, opts) 49 return auth_token.AuthProtocol(_do_cb, opts)
49 50
50 def call(self, middleware, method='GET', path='/', headers=None, 51 def call(self, middleware, method='GET', path='/', headers=None,
51 expected_status=http_client.OK): 52 expected_status=http_client.OK,
53 expected_body_string=None):
52 req = webob.Request.blank(path) 54 req = webob.Request.blank(path)
53 req.method = method 55 req.method = method
54 56
@@ -57,5 +59,7 @@ class BaseAuthTokenTestCase(utils.MiddlewareTestCase):
57 59
58 resp = req.get_response(middleware) 60 resp = req.get_response(middleware)
59 self.assertEqual(expected_status, resp.status_int) 61 self.assertEqual(expected_status, resp.status_int)
62 if expected_body_string:
63 self.assertIn(expected_body_string, six.text_type(resp.body))
60 resp.request = req 64 resp.request = req
61 return resp 65 return resp
diff --git a/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py b/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py
index 5c59d14..efcd7ef 100644
--- a/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py
+++ b/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py
@@ -1071,13 +1071,15 @@ class CommonAuthTokenMiddlewareTest(object):
1071 1071
1072 def test_http_request_max_retries(self): 1072 def test_http_request_max_retries(self):
1073 times_retry = 10 1073 times_retry = 10
1074 body_string = 'The Keystone service is temporarily unavailable.'
1074 1075
1075 conf = {'http_request_max_retries': '%s' % times_retry} 1076 conf = {'http_request_max_retries': '%s' % times_retry}
1076 self.set_middleware(conf=conf) 1077 self.set_middleware(conf=conf)
1077 1078
1078 with mock.patch('time.sleep') as mock_obj: 1079 with mock.patch('time.sleep') as mock_obj:
1079 self.call_middleware(headers={'X-Auth-Token': ERROR_TOKEN}, 1080 self.call_middleware(headers={'X-Auth-Token': ERROR_TOKEN},
1080 expected_status=503) 1081 expected_status=503,
1082 expected_body_string=body_string)
1081 1083
1082 self.assertEqual(mock_obj.call_count, times_retry) 1084 self.assertEqual(mock_obj.call_count, times_retry)
1083 1085
diff --git a/releasenotes/notes/bug-1747655-6e563d9317bb0f13.yaml b/releasenotes/notes/bug-1747655-6e563d9317bb0f13.yaml
new file mode 100644
index 0000000..65f4c5a
--- /dev/null
+++ b/releasenotes/notes/bug-1747655-6e563d9317bb0f13.yaml
@@ -0,0 +1,9 @@
1---
2fixes:
3 - |
4 [`bug/1747655 <https://bugs.launchpad.net/keystonemiddleware/+bug/1747655>`_]
5 When keystone is temporarily unavailable, keystonemiddleware correctly
6 sends a 503 response to the HTTP client but was not identifying which
7 service was down, leading to confusion on whether it was keystone or the
8 service using keystonemiddleware that was unavailable. This change
9 identifies keystone in the error response.