Revision a1741ae5 htools/Ganeti/HTools/Cluster.hs
b/htools/Ganeti/HTools/Cluster.hs | ||
---|---|---|
955 | 955 |
-- | Generic function for changing one node of an instance. |
956 | 956 |
-- |
957 | 957 |
-- This is similar to 'nodeEvacInstance' but will be used in a few of |
958 |
-- its sub-patterns. |
|
958 |
-- its sub-patterns. It folds the inner function 'evacOneNodeInner' |
|
959 |
-- over the list of available nodes, which results in the best choice |
|
960 |
-- for relocation. |
|
959 | 961 |
evacOneNodeOnly :: Node.List -- ^ The node list (cluster-wide) |
960 | 962 |
-> Instance.List -- ^ Instance list (cluster-wide) |
961 | 963 |
-> Instance.Instance -- ^ The instance to be evacuated |
... | ... | |
970 | 972 |
MirrorExternal -> Ok FailoverToAny |
971 | 973 |
(nl', inst', _, ndx) <- annotateResult "Can't find any good node" $ |
972 | 974 |
eitherToResult $ |
973 |
foldl' (evacDrbdSecondaryInner nl inst gdx op_fn)
|
|
975 |
foldl' (evacOneNodeInner nl inst gdx op_fn)
|
|
974 | 976 |
(Left "no nodes available") avail_nodes |
975 | 977 |
let idx = Instance.idx inst |
976 | 978 |
il' = Container.add idx inst' il |
977 | 979 |
ops = iMoveToJob nl' il' idx (op_fn ndx) |
978 | 980 |
return (nl', il', ops) |
979 | 981 |
|
980 |
-- | Inner fold function for changing secondary of a DRBD instance. |
|
982 |
-- | Inner fold function for changing one node of an instance. |
|
983 |
-- |
|
984 |
-- Depending on the instance disk template, this will either change |
|
985 |
-- the secondary (for DRBD) or the primary node (for shared |
|
986 |
-- storage). However, the operation is generic otherwise. |
|
981 | 987 |
-- |
982 | 988 |
-- The running solution is either a @Left String@, which means we |
983 | 989 |
-- don't have yet a working solution, or a @Right (...)@, which |
984 | 990 |
-- represents a valid solution; it holds the modified node list, the |
985 | 991 |
-- modified instance (after evacuation), the score of that solution, |
986 | 992 |
-- and the new secondary node index. |
987 |
evacDrbdSecondaryInner :: Node.List -- ^ Cluster node list
|
|
988 |
-> Instance.Instance -- ^ Instance being evacuated
|
|
989 |
-> Gdx -- ^ The group index of the instance
|
|
990 |
-> (Ndx -> IMove) -- ^ Operation constructor
|
|
991 |
-> EvacInnerState -- ^ Current best solution
|
|
992 |
-> Ndx -- ^ Node we're evaluating as new secondary
|
|
993 |
-> EvacInnerState -- ^ New best solution
|
|
994 |
evacDrbdSecondaryInner nl inst gdx op_fn accu ndx =
|
|
993 |
evacOneNodeInner :: Node.List -- ^ Cluster node list
|
|
994 |
-> Instance.Instance -- ^ Instance being evacuated |
|
995 |
-> Gdx -- ^ The group index of the instance
|
|
996 |
-> (Ndx -> IMove) -- ^ Operation constructor
|
|
997 |
-> EvacInnerState -- ^ Current best solution
|
|
998 |
-> Ndx -- ^ Node we're evaluating as target
|
|
999 |
-> EvacInnerState -- ^ New best solution
|
|
1000 |
evacOneNodeInner nl inst gdx op_fn accu ndx =
|
|
995 | 1001 |
case applyMove nl inst (op_fn ndx) of |
996 | 1002 |
OpFail fm -> |
997 | 1003 |
case accu of |
Also available in: Unified diff