Commit d4974938 authored by Klaus Aehlig's avatar Klaus Aehlig

Add an RPC to WConfD to set the maintenance delay time

...so that the user can modify it. As usual, we do so with
only a temporary lock acquired by WConfD.
Signed-off-by: 's avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: 's avatarPetr Pudlak <pudlak@google.com>
parent f19481c0
......@@ -3383,6 +3383,11 @@ class ConfigWriter(object):
if disk_uuid in inst_info.disks:
return inst_uuid
def SetMaintdRoundDelay(self, delay):
"""Set the minimal time the maintenance daemon should wait between rounds"""
utils.SimpleRetry(True, self._wconfd.SetMaintdRoundDelay, 0.1, 30,
args=[delay])
class DetachedConfig(ConfigWriter):
"""Read-only snapshot of the config."""
......
......@@ -42,9 +42,9 @@ module Ganeti.WConfd.ConfigModifications where
import Control.Applicative ((<$>))
import Control.Lens (_2)
import Control.Lens.Getter ((^.))
import Control.Lens.Setter ((.~), (%~))
import Control.Lens.Setter ((.~), (%~), (+~), over)
import Control.Lens.Traversal (mapMOf)
import Control.Monad (unless, when, forM_, foldM, liftM2)
import Control.Monad (unless, when, forM_, foldM, liftM, liftM2)
import Control.Monad.Error (throwError, MonadError)
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.State (StateT, get, put, modify,
......@@ -653,6 +653,17 @@ updateDisk disk = do
. T.releaseDRBDMinors $ uuidOf disk
return . MaybeForJSON $ fmap (_2 %~ TimeAsDoubleJSON) r
-- | Set the maintenance intervall.
setMaintdRoundDelay :: Int -> WConfdMonad Bool
setMaintdRoundDelay delay = do
now <- liftIO getClockTime
let setDelay = over (csConfigDataL . configMaintenanceL)
$ (serialL +~ 1) . (mTimeL .~ now)
. (maintRoundDelayL .~ delay)
liftM isJust $ modifyConfigWithLock
(\_ cs -> return . setDelay $ cs)
(return ())
-- * The list of functions exported to RPC.
exportedFunctions :: [Name]
......@@ -672,4 +683,5 @@ exportedFunctions = [ 'addInstance
, 'updateNetwork
, 'updateNode
, 'updateNodeGroup
, 'setMaintdRoundDelay
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment