On Tue, Jan 29, 2013 at 11:33 +0100, Iustin Pop <[email protected]> wrote:
> On Mon, Jan 28, 2013 at 07:21:43PM +0000, Dato Simó wrote:
> > Make the duration of the delay configurable with --job-delay; if not zero,
> > avoid inserting the TestDelay opcode entirely.
> "if zero" as opposed to "if not zero"?
Oops, yes; fixed (s/not //).
> > + let opcodes' = case delay of
> > + Just d -> OpTestDelay { opDelayDuration = d
> > + , opDelayOnMaster = True
> > + , opDelayOnNodes = []
> > + , opDelayRepeat = fromJust $
> > mkNonNegative 0
> > + } : opcodes
> > + Nothing -> opcodes
> > -- Third step: create repair jobs for broken instances that are in
> > ArHealthy.
> > let maybeRepair c (i, r) = maybe (return i) (repairHealthy c i) r
> > + jobDelay = optJobDelay opts
> > + repairDelay = if jobDelay > 0 -- Could use "mfilter (> 0)" after
> > + then Just jobDelay -- dropping support for 6.12.
> > + else Nothing
> Sounds good, but since the types do allow you to write "Just 0", I'm not
> sure Just/Nothing gains you anything over making the check "> 0"
> directly in doRepair.
Hmm, you're right.
> In any case, up to you, and also many thanks for documenting the
> parameters to the function.
I've changed it to checking "> 0" in doRepair. Interdiff:
--- src/Ganeti/HTools/Program/Harep.hs
+++ src/Ganeti/HTools/Program/Harep.hs
@@ -352,7 +352,7 @@
-- | Perform the suggested repair on an instance if its policy allows it.
doRepair :: L.Client -- ^ The Luxi client
- -> Maybe Double -- ^ Delay to insert before the first repair opcode
+ -> Double -- ^ Delay to insert before the first repair opcode
-> InstanceData -- ^ The instance data
-> (AutoRepairType, [OpCode]) -- ^ The repair job to perform
-> IO InstanceData -- ^ The updated instance data
@@ -399,13 +399,15 @@
-- about synchronization, but merely about speeding up the execution of
-- the harep tool. If this TestDelay opcode is removed, the program is
-- still correct.)
- let opcodes' = case delay of
- Just d -> OpTestDelay { opDelayDuration = d
- , opDelayOnMaster = True
- , opDelayOnNodes = []
- , opDelayRepeat = fromJust $ mkNonNegative
- } : opcodes
- Nothing -> opcodes
+ let opcodes' =
+ if delay > 0 then
+ OpTestDelay { opDelayDuration = delay
+ , opDelayOnMaster = True
+ , opDelayOnNodes = []
+ , opDelayRepeat = fromJust $ mkNonNegative 0
+ } : opcodes
+ else
+ opcodes
uuid <- newUUID
time <- getClockTime
@@ -453,11 +455,8 @@
-- Third step: create repair jobs for broken instances that are in ArHealthy.
let maybeRepair c (i, r) = maybe (return i) (repairHealthy c i) r
jobDelay = optJobDelay opts
- repairDelay = if jobDelay > 0 -- Could use "mfilter (> 0)" after
- then Just jobDelay -- dropping support for 6.12.
- else Nothing
repairHealthy c i = case arState i of
- ArHealthy _ -> doRepair c repairDelay i
+ ArHealthy _ -> doRepair c jobDelay i
_ -> const (return i)
repairDone <- bracket (L.getClient master) L.closeClient $
Thanks,
--
Dato Simó | [email protected]
Corp Fleet Management / Ganeti SRE (Dublin)
--
You received this message because you are subscribed to the Google Groups
"ganeti-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.