summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Eagan <sean.eagan@att.com>2019-02-25 16:27:26 -0600
committerSean Eagan <sean.eagan@att.com>2019-02-27 09:27:38 -0600
commitee02879ee0a108248fa383c27af3d2ca70eb19a9 (patch)
tree1cf236726765df3b076c15cfb03dc8a05cbf898f
parentc7d9e21b1e3c144eee54d7d2a5da3eb562255894 (diff)
Don't log health checks
Due to kubernetes liveness/readiness probes, health check logging can make the rest of the logs difficult to use. Change-Id: If063a291243cf5221b40dac47064cd25372dac95
Notes
Notes (review): Code-Review+2: Scott Hussey <sthussey@att.com> Code-Review+1: Drew Walters <drewwalters96@gmail.com> Code-Review+1: Nishant Kumar <nishant.e.kumar@ericsson.com> Code-Review+2: Bryan Strassner <strassner.bryan@gmail.com> Workflow+1: Bryan Strassner <strassner.bryan@gmail.com> Code-Review+1: Dan Crank <dan.no@att.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 28 Feb 2019 22:11:35 +0000 Reviewed-on: https://review.openstack.org/639210 Project: openstack/airship-armada Branch: refs/heads/master
-rw-r--r--armada/api/__init__.py2
-rw-r--r--armada/api/middleware.py14
-rw-r--r--armada/api/server.py4
3 files changed, 18 insertions, 2 deletions
diff --git a/armada/api/__init__.py b/armada/api/__init__.py
index df88295..ab52c17 100644
--- a/armada/api/__init__.py
+++ b/armada/api/__init__.py
@@ -27,6 +27,8 @@ from armada.handlers.tiller import Tiller
27 27
28CONF = cfg.CONF 28CONF = cfg.CONF
29 29
30HEALTH_PATH = 'health'
31
30 32
31class BaseResource(object): 33class BaseResource(object):
32 34
diff --git a/armada/api/middleware.py b/armada/api/middleware.py
index 426f23b..135ea15 100644
--- a/armada/api/middleware.py
+++ b/armada/api/middleware.py
@@ -14,6 +14,8 @@
14 14
15import re 15import re
16 16
17from armada.api import HEALTH_PATH
18
17from uuid import UUID 19from uuid import UUID
18 20
19from oslo_config import cfg 21from oslo_config import cfg
@@ -100,9 +102,18 @@ class LoggingMiddleware(object):
100 # don't log any headers beginning with X-* 102 # don't log any headers beginning with X-*
101 hdr_exclude = re.compile('x-.*', re.IGNORECASE) 103 hdr_exclude = re.compile('x-.*', re.IGNORECASE)
102 104
105 # don't log anything for health checks
106 path_exclude = re.compile('.*/{}$'.format(HEALTH_PATH))
107
108 def exclude_path(self, req):
109 return LoggingMiddleware.path_exclude.match(req.path)
110
103 def process_request(self, req, resp): 111 def process_request(self, req, resp):
104 """ Set up values to be logged across the request 112 """ Set up values to be logged across the request
105 """ 113 """
114 if self.exclude_path(req):
115 return
116
106 ctx = req.context 117 ctx = req.context
107 extra = { 118 extra = {
108 'user': ctx.user, 119 'user': ctx.user,
@@ -115,6 +126,9 @@ class LoggingMiddleware(object):
115 def process_response(self, req, resp, resource, req_succeeded): 126 def process_response(self, req, resp, resource, req_succeeded):
116 """ Log the response information 127 """ Log the response information
117 """ 128 """
129 if self.exclude_path(req):
130 return
131
118 ctx = req.context 132 ctx = req.context
119 extra = { 133 extra = {
120 'user': ctx.user, 134 'user': ctx.user,
diff --git a/armada/api/server.py b/armada/api/server.py
index a8e6490..c32b5a9 100644
--- a/armada/api/server.py
+++ b/armada/api/server.py
@@ -18,7 +18,7 @@ from oslo_policy import policy
18from oslo_log import log as logging 18from oslo_log import log as logging
19 19
20from armada import conf 20from armada import conf
21from armada.api import ArmadaRequest 21from armada.api import ArmadaRequest, HEALTH_PATH
22from armada.api.controller.armada import Apply 22from armada.api.controller.armada import Apply
23from armada.api.middleware import AuthMiddleware 23from armada.api.middleware import AuthMiddleware
24from armada.api.middleware import ContextMiddleware 24from armada.api.middleware import ContextMiddleware
@@ -60,7 +60,7 @@ def create(enable_middleware=CONF.middleware):
60 60
61 # Configure API routing 61 # Configure API routing
62 url_routes_v1 = ( 62 url_routes_v1 = (
63 ('health', Health()), 63 (HEALTH_PATH, Health()),
64 ('apply', Apply()), 64 ('apply', Apply()),
65 ('releases', Release()), 65 ('releases', Release()),
66 ('rollback/{release}', Rollback()), 66 ('rollback/{release}', Rollback()),