chore(avs): fix #34 by scheduling avs background updates
This commit is contained in:
parent
c33964750d
commit
132a0438ef
@ -81,8 +81,11 @@ health-check-ldap-admins-timeout: "_env:HEALTHCHECK_LDAP_ADMINS_TIMEOUT:60"
|
|||||||
health-check-http-reachable-timeout: "_env:HEALTHCHECK_HTTP_REACHABLE_TIMEOUT:2"
|
health-check-http-reachable-timeout: "_env:HEALTHCHECK_HTTP_REACHABLE_TIMEOUT:2"
|
||||||
health-check-matching-cluster-config-timeout: "_env:HEALTHCHECK_MATCHING_CLUSTER_CONFIG_TIMEOUT:2"
|
health-check-matching-cluster-config-timeout: "_env:HEALTHCHECK_MATCHING_CLUSTER_CONFIG_TIMEOUT:2"
|
||||||
|
|
||||||
synchronise-ldap-users-within: "_env:SYNCHRONISE_LDAP_WITHIN:1209600"
|
synchronise-ldap-users-within: "_env:SYNCHRONISE_LDAP_WITHIN:1209600" # 14 Tage in Sekunden
|
||||||
synchronise-ldap-users-interval: "_env:SYNCHRONISE_LDAP_INTERVAL:3600"
|
synchronise-ldap-users-interval: "_env:SYNCHRONISE_LDAP_INTERVAL:3600" # jede Stunde
|
||||||
|
|
||||||
|
synchronise-avs-users-within: "_env:SYNCHRONISE_AVS_WITHIN:5702400" # alle 66 Tage
|
||||||
|
synchronise-avs-users-interval: "_env:SYNCHRONISE_AVS_INTERVAL:21600" # alle 6 Stunden
|
||||||
|
|
||||||
study-features-recache-relevance-within: 172800
|
study-features-recache-relevance-within: 172800
|
||||||
study-features-recache-relevance-interval: 293
|
study-features-recache-relevance-interval: 293
|
||||||
|
|||||||
@ -56,7 +56,8 @@ getAdminProblemsR = do
|
|||||||
(Left e) -> return $ Left $ text2widget $ tshow (e :: SomeException)
|
(Left e) -> return $ Left $ text2widget $ tshow (e :: SomeException)
|
||||||
(Right AvsLicenceDifferences{..}) -> do
|
(Right AvsLicenceDifferences{..}) -> do
|
||||||
let problemIds = avsLicenceDiffRevokeAll <> avsLicenceDiffGrantVorfeld <> avsLicenceDiffRevokeRollfeld <> avsLicenceDiffGrantRollfeld
|
let problemIds = avsLicenceDiffRevokeAll <> avsLicenceDiffGrantVorfeld <> avsLicenceDiffRevokeRollfeld <> avsLicenceDiffGrantRollfeld
|
||||||
mapM_ (queueJob' . flip JobSynchroniseAvsId cutOffAvsSynch) problemIds
|
-- mapM_ (queueJob' . flip JobSynchroniseAvsId cutOffAvsSynch) problemIds
|
||||||
|
runDBJobs . forM_ problemIds $ queueDBJob . flip JobSynchroniseAvsId cutOffAvsSynch
|
||||||
return $ Right
|
return $ Right
|
||||||
( Set.size avsLicenceDiffRevokeAll
|
( Set.size avsLicenceDiffRevokeAll
|
||||||
, Set.size avsLicenceDiffGrantVorfeld
|
, Set.size avsLicenceDiffGrantVorfeld
|
||||||
|
|||||||
@ -332,6 +332,30 @@ determineCrontab = execWriterT $ do
|
|||||||
| otherwise
|
| otherwise
|
||||||
-> return ()
|
-> return ()
|
||||||
|
|
||||||
|
if
|
||||||
|
| is _Just appAvsConf
|
||||||
|
, Just syncWithin <- appSynchroniseAvsUsersWithin
|
||||||
|
, Just cInterval <- appJobCronInterval
|
||||||
|
-> do
|
||||||
|
nextIntervals <- getNextIntervals syncWithin appSynchroniseAvsUsersInterval cInterval
|
||||||
|
|
||||||
|
forM_ nextIntervals $ \(nextEpoch, nextInterval, nextIntervalTime, numIntervals) -> do
|
||||||
|
tell $ HashMap.singleton
|
||||||
|
(JobCtlQueue JobSynchroniseAvs
|
||||||
|
{ jEpoch = fromInteger nextEpoch
|
||||||
|
, jNumIterations = fromInteger numIntervals
|
||||||
|
, jIteration = fromInteger nextInterval
|
||||||
|
, jSynchAfter = Nothing
|
||||||
|
})
|
||||||
|
Cron
|
||||||
|
{ cronInitial = CronTimestamp $ utcToLocalTimeTZ appTZ nextIntervalTime
|
||||||
|
, cronRepeat = CronRepeatNever
|
||||||
|
, cronRateLimit = appSynchroniseLdapUsersInterval
|
||||||
|
, cronNotAfter = Right . CronTimestamp . utcToLocalTimeTZ appTZ $ addUTCTime appSynchroniseAvsUsersInterval nextIntervalTime
|
||||||
|
}
|
||||||
|
| otherwise
|
||||||
|
-> return ()
|
||||||
|
|
||||||
whenIsJust ((,) <$> appPruneUnreferencedFilesWithin <*> appJobCronInterval) $ \(within, cInterval) -> do
|
whenIsJust ((,) <$> appPruneUnreferencedFilesWithin <*> appJobCronInterval) $ \(within, cInterval) -> do
|
||||||
nextIntervals <- getNextIntervals within appPruneUnreferencedFilesInterval cInterval
|
nextIntervals <- getNextIntervals within appPruneUnreferencedFilesInterval cInterval
|
||||||
forM_ nextIntervals $ \(nextEpoch, nextInterval, nextIntervalTime, numIntervals) -> do
|
forM_ nextIntervals $ \(nextEpoch, nextInterval, nextIntervalTime, numIntervals) -> do
|
||||||
|
|||||||
@ -89,6 +89,11 @@ data Job
|
|||||||
, jIteration :: Natural
|
, jIteration :: Natural
|
||||||
}
|
}
|
||||||
| JobSynchroniseLdapUser { jUser :: UserId }
|
| JobSynchroniseLdapUser { jUser :: UserId }
|
||||||
|
| JobSynchroniseAvs { jNumIterations
|
||||||
|
, jEpoch
|
||||||
|
, jIteration :: Natural
|
||||||
|
, jSynchAfter :: Maybe UTCTime
|
||||||
|
}
|
||||||
| JobSynchroniseAvsUser { jUser :: UserId
|
| JobSynchroniseAvsUser { jUser :: UserId
|
||||||
, jSynchAfter :: Maybe UTCTime
|
, jSynchAfter :: Maybe UTCTime
|
||||||
}
|
}
|
||||||
|
|||||||
@ -165,6 +165,9 @@ data AppSettings = AppSettings
|
|||||||
, appSynchroniseLdapUsersWithin :: Maybe NominalDiffTime
|
, appSynchroniseLdapUsersWithin :: Maybe NominalDiffTime
|
||||||
, appSynchroniseLdapUsersInterval :: NominalDiffTime
|
, appSynchroniseLdapUsersInterval :: NominalDiffTime
|
||||||
|
|
||||||
|
, appSynchroniseAvsUsersWithin :: Maybe NominalDiffTime
|
||||||
|
, appSynchroniseAvsUsersInterval :: NominalDiffTime
|
||||||
|
|
||||||
, appLdapReTestFailover :: DiffTime
|
, appLdapReTestFailover :: DiffTime
|
||||||
|
|
||||||
, appSessionFilesExpire :: NominalDiffTime
|
, appSessionFilesExpire :: NominalDiffTime
|
||||||
@ -690,9 +693,12 @@ instance FromJSON AppSettings where
|
|||||||
|
|
||||||
appSessionTimeout <- o .: "session-timeout"
|
appSessionTimeout <- o .: "session-timeout"
|
||||||
|
|
||||||
appSynchroniseLdapUsersWithin <- o .:? "synchronise-ldap-users-within"
|
appSynchroniseLdapUsersWithin <- o .:? "synchronise-ldap-users-within"
|
||||||
appSynchroniseLdapUsersInterval <- o .: "synchronise-ldap-users-interval"
|
appSynchroniseLdapUsersInterval <- o .: "synchronise-ldap-users-interval"
|
||||||
|
|
||||||
|
appSynchroniseAvsUsersWithin <- o .:? "synchronise-avs-users-within"
|
||||||
|
appSynchroniseAvsUsersInterval <- o .: "synchronise-avs-users-interval"
|
||||||
|
|
||||||
appLdapReTestFailover <- o .: "ldap-re-test-failover"
|
appLdapReTestFailover <- o .: "ldap-re-test-failover"
|
||||||
|
|
||||||
appSessionFilesExpire <- o .: "session-files-expire"
|
appSessionFilesExpire <- o .: "session-files-expire"
|
||||||
|
|||||||
Reference in New Issue
Block a user