fix(health): monitor flush by check interval not flush interval

This commit is contained in:
Gregor Kleen 2021-06-28 10:23:18 +02:00
parent fb7b63394a
commit 03226eca6a
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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