summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Benton <kevin@benton.pub>2016-12-30 02:29:39 -0800
committerBoris Bobrov <bbobrov@mirantis.com>2016-12-31 13:37:31 +0000
commitdfd53e55512cba6a8b7e69ac5bf7bea172dfe6b1 (patch)
treef98d547693f3eb72d9171441635e99347371f8fc
parent20fb1dbe5a884ecdbf6ee5ea26b2660f7a7e4b1e (diff)
downloadkeystonemiddleware-dfd53e55512cba6a8b7e69ac5bf7bea172dfe6b1.tar.gz
Limit deprecated token message to single warning4.13.0
The current behavior of a deprecation warning on every single request is making the logs very difficult to scan for other problems. One deprecation warning per run should be enough to get the message across. This patch ensures only one warning per lifetime of the middleware object. Change-Id: I481a1b11305cc1c90edf7e26c686824c32fe781f Closes-Bug: #1652929
-rw-r--r--keystonemiddleware/auth_token/__init__.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/keystonemiddleware/auth_token/__init__.py b/keystonemiddleware/auth_token/__init__.py
index a136a65..5ac66dc 100644
--- a/keystonemiddleware/auth_token/__init__.py
+++ b/keystonemiddleware/auth_token/__init__.py
@@ -324,6 +324,7 @@ class BaseAuthProtocol(object):
self._enforce_token_bind = enforce_token_bind
self._service_token_roles = set(service_token_roles or [])
self._service_token_roles_required = service_token_roles_required
+ self._service_token_warning_emitted = False
@webob.dec.wsgify(RequestClass=_request._AuthTokenRequest)
def __call__(self, req):
@@ -381,12 +382,15 @@ class BaseAuthProtocol(object):
if self._service_token_roles_required:
request.service_token_valid = role_check_passed
else:
- self.log.warning(_LW('A valid token was submitted as a '
- 'service token, but it was not a '
- 'valid service token. This is '
- 'incorrect but backwards compatible '
- 'behaviour. This will be removed in '
- 'future releases.'))
+ if not self._service_token_warning_emitted:
+ self.log.warning(_LW('A valid token was submitted as '
+ 'a service token, but it was not '
+ 'a valid service token. This is '
+ 'incorrect but backwards '
+ 'compatible behaviour. This will '
+ 'be removed in future releases.'))
+ # prevent log spam on every single request
+ self._service_token_warning_emitted = True
request.service_token_valid = True