From 681f16be93ebbea69a67cfadd2d94af89fa2233d Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Fri, 14 Jul 2023 11:15:59 +0000 Subject: [PATCH] chore(health): adjust health evalutation --- messages/uniworx/categories/health/de-de-formal.msg | 2 +- messages/uniworx/categories/health/en-eu.msg | 2 +- src/Application.hs | 6 +++--- src/Jobs.hs | 2 +- src/Model/Types/Health.hs | 13 +++++++------ 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/messages/uniworx/categories/health/de-de-formal.msg b/messages/uniworx/categories/health/de-de-formal.msg index 75aa473dd..2c8355493 100644 --- a/messages/uniworx/categories/health/de-de-formal.msg +++ b/messages/uniworx/categories/health/de-de-formal.msg @@ -9,7 +9,7 @@ HealthCheckLDAPAdmins: Anteil der Administrator:innen mit LDAP Authentifizierung HealthCheckSMTPConnect: SMTP-Server kann erreicht werden HealthCheckWidgetMemcached: Memcached-Server liefert Widgets korrekt aus HealthCheckActiveJobExecutors: Anteil der job-workers, die neue Befehle annehmen -HealthCheckDoesFlush: Zustandsprüfung läuft durch +HealthCheckDoesFlush: Abgearbeitete Jobs werden aufgeräumt InstanceIdentification: Instanz-Identifikation InstanceId: Instanz-Nummer ClusterId: Cluster-Nummer \ No newline at end of file diff --git a/messages/uniworx/categories/health/en-eu.msg b/messages/uniworx/categories/health/en-eu.msg index 948a7c4cc..4e24bd8bb 100644 --- a/messages/uniworx/categories/health/en-eu.msg +++ b/messages/uniworx/categories/health/en-eu.msg @@ -9,7 +9,7 @@ HealthCheckLDAPAdmins: Proportion of administrators with LDAP authentication tha HealthCheckSMTPConnect: SMTP server is reachable HealthCheckWidgetMemcached: Memcached server is serving widgets correctly HealthCheckActiveJobExecutors: Proportion of job workers accepting new jobs -HealthCheckDoesFlush: Health reports flushes +HealthCheckDoesFlush: Executed jobs are removed InstanceIdentification: Instance identification InstanceId: Instance id ClusterId: Cluster id diff --git a/src/Application.hs b/src/Application.hs index 6592a8342..90d344bfd 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -550,8 +550,8 @@ warpSettings foundation = defaultSettings & Set.filter (is _Just . (foundation ^. _appHealthCheckInterval)) atomically $ do results <- readTVar $ foundation ^. _appHealthReport - guard $ activeChecks == Set.map (classifyHealthReport . snd) results - guard . (== Min HealthSuccess) $ foldMap (Min . healthReportStatus . snd) results + guard $ activeChecks `Set.isSubsetOf` Set.map (classifyHealthReport . snd) results + guard . (/= Min HealthFailure) $ foldMap (Min . healthReportStatus . snd) results notifyReady | otherwise -> notifyReady @@ -679,7 +679,7 @@ appMain = runResourceT $ do interval <- mInterval let lastSuccess = maybeMonoid mResults & Set.filter (\(_, rep) -> classifyHealthReport rep == hc) - & Set.filter (\(_, rep) -> healthReportStatus rep >= HealthSuccess) + & Set.filter (\(_, rep) -> healthReportStatus rep > HealthFailure) & Set.mapMonotonic (view _1) & Set.lookupMax diff --git a/src/Jobs.hs b/src/Jobs.hs index c658668dc..0d5993ce7 100644 --- a/src/Jobs.hs +++ b/src/Jobs.hs @@ -593,7 +593,7 @@ handleJobs' wNum = C.mapM_ $ \jctl -> hoist delimitInternalState . withJobWorker newReport@(healthReportStatus -> newStatus) <- lift $ generateHealthReport kind $logInfoS logIdent [st|#{tshow kind}: #{toPathPiece newStatus}|] - unless (newStatus == HealthSuccess) $ do + unless (newStatus > HealthFailure) $ do $logErrorS logIdent [st|#{tshow kind}: #{tshow newReport}|] liftIO $ do diff --git a/src/Model/Types/Health.hs b/src/Model/Types/Health.hs index 36f4be750..64ad49b3a 100644 --- a/src/Model/Types/Health.hs +++ b/src/Model/Types/Health.hs @@ -67,10 +67,10 @@ classifyHealthReport :: HealthReport -> HealthCheck classifyHealthReport HealthMatchingClusterConfig{} = HealthCheckMatchingClusterConfig classifyHealthReport HealthLDAPAdmins{} = HealthCheckLDAPAdmins classifyHealthReport HealthHTTPReachable{} = HealthCheckHTTPReachable -classifyHealthReport HealthSMTPConnect{} = HealthCheckSMTPConnect -classifyHealthReport HealthWidgetMemcached{} = HealthCheckWidgetMemcached -classifyHealthReport HealthActiveJobExecutors{} = HealthCheckActiveJobExecutors -classifyHealthReport HealthDoesFlush{} = HealthCheckDoesFlush +classifyHealthReport HealthSMTPConnect{} = HealthCheckSMTPConnect +classifyHealthReport HealthWidgetMemcached{} = HealthCheckWidgetMemcached -- kein Neustart notwendig +classifyHealthReport HealthActiveJobExecutors{} = HealthCheckActiveJobExecutors +classifyHealthReport HealthDoesFlush{} = HealthCheckDoesFlush -- evtl. kein Neustart notwendig -- | `HealthReport` classified (`classifyHealthReport`) by badness -- @@ -111,7 +111,8 @@ healthReportStatus = \case HealthActiveJobExecutors Nothing -> HealthInactive HealthActiveJobExecutors (Just prop ) | prop > 0 -> HealthSuccess - HealthDoesFlush mProp - | maybe True (>= 2) mProp -> HealthFailure -- Looks buggy to me? + HealthDoesFlush Nothing -> HealthInactive + HealthDoesFlush (Just prop ) + | prop >= 2 -> HealthFailure | otherwise -> HealthSuccess _other -> HealthFailure