configReloadRatelimit :: Int
configReloadRatelimit = C.confdConfigReloadRatelimit * 1000000
+-- | Ratelimit timeout in seconds, as an 'Integer'.
+reloadRatelimitSec :: Integer
+reloadRatelimitSec = fromIntegral C.confdConfigReloadRatelimit
+
-- | Initial poll round.
initialPoll :: ReloadModel
initialPoll = ReloadPoll 0
ctime <- getCurrentTime
(newfstat, _) <- safeUpdateConfig path (reloadFStat state) cref
let state' = state { reloadFStat = newfstat, reloadTime = ctime }
- if abs (reloadTime state - ctime) <
- fromIntegral C.confdConfigReloadRatelimit
+ if abs (reloadTime state - ctime) < reloadRatelimitSec
then do
mode <- moveToPolling "too many reloads" inotify path cref mstate
return state' { reloadModel = mode }
import Ganeti.JSON
import Ganeti.Utils
+-- | Type-adjusted max clock skew constant.
+maxClockSkew :: Integer
+maxClockSkew = fromIntegral C.confdMaxClockSkew
+
-- | Returns the HMAC key.
getClusterHmac :: IO HashKey
getClusterHmac = Path.confdHmacKey >>= fmap B.unpack . B.readFile
parseMessage hmac msg curtime = do
(salt, origmsg, request) <- parseRequest hmac msg
ts <- tryRead "Parsing timestamp" salt::Result Integer
- if abs (ts - curtime) > fromIntegral C.confdMaxClockSkew
+ if abs (ts - curtime) > maxClockSkew
then fail "Too old/too new timestamp or clock skew"
else return (origmsg, request)