Skip to content
Snippets Groups Projects
Commit 80b27509 authored by Iustin Pop's avatar Iustin Pop
Browse files

Rework evacDrbdSecondaryInner to take the imove


Instead of hard-coding the instance move operation, let's accept is as
a parameter from the caller. This is the single thing that makes this
DRBD-specific, so removing it will help for future
patches. Furthermore, this abstract the imove op type into a single
place instead of two (the inner function and the nodeEvacInstance).

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent bebe7a73
No related branches found
No related tags found
No related merge requests found
...@@ -898,13 +898,14 @@ nodeEvacInstance nl il ChangeSecondary ...@@ -898,13 +898,14 @@ nodeEvacInstance nl il ChangeSecondary
inst@(Instance.Instance {Instance.diskTemplate = DTDrbd8}) inst@(Instance.Instance {Instance.diskTemplate = DTDrbd8})
gdx avail_nodes = gdx avail_nodes =
do do
let op_fn = ReplaceSecondary
(nl', inst', _, ndx) <- annotateResult "Can't find any good node" $ (nl', inst', _, ndx) <- annotateResult "Can't find any good node" $
eitherToResult $ eitherToResult $
foldl' (evacDrbdSecondaryInner nl inst gdx) foldl' (evacDrbdSecondaryInner nl inst gdx op_fn)
(Left "no nodes available") avail_nodes (Left "no nodes available") avail_nodes
let idx = Instance.idx inst let idx = Instance.idx inst
il' = Container.add idx inst' il il' = Container.add idx inst' il
ops = iMoveToJob nl' il' idx (ReplaceSecondary ndx) ops = iMoveToJob nl' il' idx (op_fn ndx)
return (nl', il', ops) return (nl', il', ops)
-- The algorithm for ChangeAll is as follows: -- The algorithm for ChangeAll is as follows:
...@@ -956,11 +957,12 @@ nodeEvacInstance nl il ChangeAll ...@@ -956,11 +957,12 @@ nodeEvacInstance nl il ChangeAll
evacDrbdSecondaryInner :: Node.List -- ^ Cluster node list evacDrbdSecondaryInner :: Node.List -- ^ Cluster node list
-> Instance.Instance -- ^ Instance being evacuated -> Instance.Instance -- ^ Instance being evacuated
-> Gdx -- ^ The group index of the instance -> Gdx -- ^ The group index of the instance
-> (Ndx -> IMove) -- ^ Operation constructor
-> EvacInnerState -- ^ Current best solution -> EvacInnerState -- ^ Current best solution
-> Ndx -- ^ Node we're evaluating as new secondary -> Ndx -- ^ Node we're evaluating as new secondary
-> EvacInnerState -- ^ New best solution -> EvacInnerState -- ^ New best solution
evacDrbdSecondaryInner nl inst gdx accu ndx = evacDrbdSecondaryInner nl inst gdx op_fn accu ndx =
case applyMove nl inst (ReplaceSecondary ndx) of case applyMove nl inst (op_fn ndx) of
OpFail fm -> OpFail fm ->
case accu of case accu of
Right _ -> accu Right _ -> accu
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment