From 84930b4924eefc2dcc5afe5918016ce5e891d31e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 29 Apr 2022 11:15:54 +0000 Subject: [PATCH] Revert "internal: fix high cpu when backend isnt healthy" This reverts commit eb6cfd22a72970dfdab0314d4f1bd3038d3b88c7. Revert "root: handle JSON error in metrics too" This reverts commit 1ede97222260d00a3ae25aa2a4f7de6c6e562271. Revert "root: don't force multiprocess prometheus registry" This reverts commit cd1d1b440296a4c15059b4ec1c2adeec797ff220. Revert "root: add error handling for prometheus view" This reverts commit c0a883f76fdc4df0be89fa240aad1334250915ad. --- authentik/root/monitoring.py | 6 +----- internal/gounicorn/gounicorn.go | 20 +++++++------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/authentik/root/monitoring.py b/authentik/root/monitoring.py index 17deefb65..2c0b2d129 100644 --- a/authentik/root/monitoring.py +++ b/authentik/root/monitoring.py @@ -1,6 +1,5 @@ """Metrics view""" from base64 import b64encode -from json import JSONDecodeError from django.conf import settings from django.db import connections @@ -32,10 +31,7 @@ class MetricsView(View): monitoring_set.send_robust(self) - try: - return ExportToDjangoView(request) - except (UnicodeDecodeError, KeyError, ValueError, JSONDecodeError): - return HttpResponse(status_code=500) + return ExportToDjangoView(request) class LiveView(View): diff --git a/internal/gounicorn/gounicorn.go b/internal/gounicorn/gounicorn.go index a63cc43ac..f41f219b3 100644 --- a/internal/gounicorn/gounicorn.go +++ b/internal/gounicorn/gounicorn.go @@ -83,20 +83,14 @@ func (g *GoUnicorn) healthcheck() { // Default healthcheck is every 1 second on startup // once we've been healthy once, increase to 30 seconds - func() { - for { - select { - case <-time.Tick(1 * time.Second): - if check() { - g.log.Info("backend is alive, backing off with healthchecks") - g.HealthyCallback() - return - } else { - g.log.Debug("backend not alive yet") - } - } + for range time.Tick(time.Second) { + if check() { + g.log.Info("backend is alive, backing off with healthchecks") + g.HealthyCallback() + break } - }() + g.log.Debug("backend not alive yet") + } for range time.Tick(30 * time.Second) { check() }