Skip db preload on healtchcheck requests
Some checks failed
Run tests and linters / test (pull_request) Successful in 3m3s
Run tests and linters / lint (pull_request) Failing after 2s

Every web request triggers a db query to preload app header data. In case of health checks
we do not need to preload anything and can safely skip the @app.before_request.

Fixes #310
This commit is contained in:
Jaroslav Groman 2026-05-25 13:18:17 +02:00
commit 0825933f91

View file

@ -35,11 +35,15 @@ from blockerbugs.models.update import Update
from blockerbugs.models.release import Release
from blockerbugs.controllers.forms import BugProposeForm
HEALTH_CHECK_PATH = '/_health'
main = Blueprint('main', __name__)
@app.before_request
def before_request():
if request.path == HEALTH_CHECK_PATH:
return
g.milestones = Milestone.query.filter_by(active=True).order_by(Milestone.name).all()
g.version = __version__
g.version_date = misc.version_date()
@ -279,7 +283,7 @@ def index():
return display_current()
@main.route('/_health')
@main.route(HEALTH_CHECK_PATH)
def get_health_check():
"""Endpoint for OpenShift pod health checks (liveness and readiness probes).