From 03226eca6aba91e2f10f5828a38f2a15d747dd0c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 28 Jun 2021 10:23:18 +0200 Subject: [PATCH] fix(health): monitor flush by check interval not flush interval --- src/Jobs/HealthReport.hs | 5 +++-- src/Model/Types/Health.hs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Jobs/HealthReport.hs b/src/Jobs/HealthReport.hs index ec6debd87..7d26e6226 100644 --- a/src/Jobs/HealthReport.hs +++ b/src/Jobs/HealthReport.hs @@ -179,10 +179,11 @@ dispatchHealthCheckDoesFlush :: Handler HealthReport dispatchHealthCheckDoesFlush = fmap HealthDoesFlush . runMaybeT $ do UniWorX{ appSettings' = AppSettings{..}, appJobState } <- getYesod - interval <- hoistMaybe $ guardOnM (isn't _JobsOffload appJobMode) appJobFlushInterval + guard . is _Just $ guardOnM (isn't _JobsOffload appJobMode) appJobFlushInterval + checkInterval <- hoistMaybe $ appHealthCheckInterval HealthCheckDoesFlush lFlush <- MaybeT . atomically $ do jState <- tryReadTMVar appJobState fmap join . for jState $ \JobState{jobContext} -> readTVar $ jobLastFlush jobContext now <- liftIO getCurrentTime - return $ toRational (now `diffUTCTime` lFlush) / toRational interval + return $ toRational (now `diffUTCTime` lFlush) / toRational checkInterval diff --git a/src/Model/Types/Health.hs b/src/Model/Types/Health.hs index 6cacd2148..137810be8 100644 --- a/src/Model/Types/Health.hs +++ b/src/Model/Types/Health.hs @@ -95,5 +95,5 @@ healthReportStatus = \case HealthActiveJobExecutors (Just prop ) | prop <= 0 -> HealthFailure HealthDoesFlush (Just prop ) - | prop >= 2 -> HealthFailure + | prop >= 1 -> HealthFailure _other -> maxBound -- Minimum badness