Revision 6ab3ce90
b/htools/Ganeti/HTools/Cluster.hs | ||
---|---|---|
911 | 911 |
nodeEvacInstance nl il ChangeSecondary |
912 | 912 |
inst@(Instance.Instance {Instance.diskTemplate = DTDrbd8}) |
913 | 913 |
gdx avail_nodes = |
914 |
do |
|
915 |
let op_fn = ReplaceSecondary |
|
916 |
(nl', inst', _, ndx) <- annotateResult "Can't find any good node" $ |
|
917 |
eitherToResult $ |
|
918 |
foldl' (evacDrbdSecondaryInner nl inst gdx op_fn) |
|
919 |
(Left "no nodes available") avail_nodes |
|
920 |
let idx = Instance.idx inst |
|
921 |
il' = Container.add idx inst' il |
|
922 |
ops = iMoveToJob nl' il' idx (op_fn ndx) |
|
923 |
return (nl', il', ops) |
|
914 |
evacOneNodeOnly nl il inst gdx avail_nodes |
|
924 | 915 |
|
925 | 916 |
-- The algorithm for ChangeAll is as follows: |
926 | 917 |
-- |
... | ... | |
961 | 952 |
|
962 | 953 |
return (nl', il', ops) |
963 | 954 |
|
955 |
-- | Generic function for changing one node of an instance. |
|
956 |
-- |
|
957 |
-- This is similar to 'nodeEvacInstance' but will be used in a few of |
|
958 |
-- its sub-patterns. |
|
959 |
evacOneNodeOnly :: Node.List -- ^ The node list (cluster-wide) |
|
960 |
-> Instance.List -- ^ Instance list (cluster-wide) |
|
961 |
-> Instance.Instance -- ^ The instance to be evacuated |
|
962 |
-> Gdx -- ^ The group we're targetting |
|
963 |
-> [Ndx] -- ^ The list of available nodes |
|
964 |
-- for allocation |
|
965 |
-> Result (Node.List, Instance.List, [OpCodes.OpCode]) |
|
966 |
evacOneNodeOnly nl il inst gdx avail_nodes = do |
|
967 |
op_fn <- case templateMirrorType (Instance.diskTemplate inst) of |
|
968 |
MirrorNone -> Bad "Can't relocate/evacuate non-mirrored instances" |
|
969 |
MirrorInternal -> Ok ReplaceSecondary |
|
970 |
MirrorExternal -> Ok FailoverToAny |
|
971 |
(nl', inst', _, ndx) <- annotateResult "Can't find any good node" $ |
|
972 |
eitherToResult $ |
|
973 |
foldl' (evacDrbdSecondaryInner nl inst gdx op_fn) |
|
974 |
(Left "no nodes available") avail_nodes |
|
975 |
let idx = Instance.idx inst |
|
976 |
il' = Container.add idx inst' il |
|
977 |
ops = iMoveToJob nl' il' idx (op_fn ndx) |
|
978 |
return (nl', il', ops) |
|
979 |
|
|
964 | 980 |
-- | Inner fold function for changing secondary of a DRBD instance. |
965 | 981 |
-- |
966 | 982 |
-- The running solution is either a @Left String@, which means we |
Also available in: Unified diff