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
This commit is contained in:
Sean Eagan 2019-02-25 16:27:26 -06:00
parent c7d9e21b1e
commit ee02879ee0
3 changed files with 18 additions and 2 deletions

View File

@ -27,6 +27,8 @@ from armada.handlers.tiller import Tiller
CONF = cfg.CONF
HEALTH_PATH = 'health'
class BaseResource(object):

View File

@ -14,6 +14,8 @@
import re
from armada.api import HEALTH_PATH
from uuid import UUID
from oslo_config import cfg
@ -100,9 +102,18 @@ class LoggingMiddleware(object):
# don't log any headers beginning with X-*
hdr_exclude = re.compile('x-.*', re.IGNORECASE)
# don't log anything for health checks
path_exclude = re.compile('.*/{}$'.format(HEALTH_PATH))
def exclude_path(self, req):
return LoggingMiddleware.path_exclude.match(req.path)
def process_request(self, req, resp):
""" Set up values to be logged across the request
"""
if self.exclude_path(req):
return
ctx = req.context
extra = {
'user': ctx.user,
@ -115,6 +126,9 @@ class LoggingMiddleware(object):
def process_response(self, req, resp, resource, req_succeeded):
""" Log the response information
"""
if self.exclude_path(req):
return
ctx = req.context
extra = {
'user': ctx.user,

View File

@ -18,7 +18,7 @@ from oslo_policy import policy
from oslo_log import log as logging
from armada import conf
from armada.api import ArmadaRequest
from armada.api import ArmadaRequest, HEALTH_PATH
from armada.api.controller.armada import Apply
from armada.api.middleware import AuthMiddleware
from armada.api.middleware import ContextMiddleware
@ -60,7 +60,7 @@ def create(enable_middleware=CONF.middleware):
# Configure API routing
url_routes_v1 = (
('health', Health()),
(HEALTH_PATH, Health()),
('apply', Apply()),
('releases', Release()),
('rollback/{release}', Rollback()),