This brings together all previous pieces and allows balancing to work
(with the known caveats related to disk space calculation) for shared
storage disk templates.
---
htools/Ganeti/HTools/Cluster.hs | 20 +++++++++++++++++++-
htools/Ganeti/HTools/Types.hs | 2 ++
2 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs
index 0b1617a..6593aa6 100644
--- a/htools/Ganeti/HTools/Cluster.hs
+++ b/htools/Ganeti/HTools/Cluster.hs
@@ -395,6 +395,17 @@ applyMove nl inst Failover =
new_inst, old_sdx, old_pdx)
in new_nl
+-- Failover to any (fa)
+applyMove nl inst (FailoverToAny new_pdx) =
+ let (old_pdx, old_sdx, old_p, _) = instanceNodes nl inst
+ tgt_n = Container.find new_pdx nl
+ !new_nl = do -- Maybe monad
+ new_p <- Node.addPriEx (Node.offline old_p) tgt_n inst
+ let new_inst = Instance.setPri inst new_pdx
+ return (Container.addTwo old_pdx (Node.removePri old_p inst)
+ new_pdx new_p nl, new_inst, new_pdx, old_sdx)
+ in new_nl
+
-- Replace the primary (f:, r:np, f)
applyMove nl inst (ReplacePrimary new_pdx) =
let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
@@ -520,7 +531,10 @@ possibleMoves :: MirrorType -- ^ The mirroring type of the
instance
possibleMoves MirrorNone _ _ _ = []
-possibleMoves MirrorExternal _ _ _ = []
+possibleMoves MirrorExternal _ False _ = []
+
+possibleMoves MirrorExternal _ True tdx =
+ [ FailoverToAny tdx ]
possibleMoves MirrorInternal _ False tdx =
[ ReplaceSecondary tdx ]
@@ -1215,12 +1229,14 @@ computeMoves :: Instance.Instance -- ^ The instance to
be moved
computeMoves i inam mv c d =
case mv of
Failover -> ("f", [mig])
+ FailoverToAny _ -> (printf "fa:%s" c, [mig_any])
FailoverAndReplace _ -> (printf "f r:%s" d, [mig, rep d])
ReplaceSecondary _ -> (printf "r:%s" d, [rep d])
ReplaceAndFailover _ -> (printf "r:%s f" c, [rep c, mig])
ReplacePrimary _ -> (printf "f r:%s f" c, [mig, rep c, mig])
where morf = if Instance.isRunning i then "migrate" else "failover"
mig = printf "%s -f %s" morf inam::String
+ mig_any = printf "%s -f -n %s %s" morf c inam
rep n = printf "replace-disks -n %s %s" n inam
-- | Converts a placement to string format.
@@ -1374,10 +1390,12 @@ iMoveToJob nl il idx move =
iname = Instance.name inst
lookNode = Just . Container.nameOf nl
opF = OpCodes.OpInstanceMigrate iname True False True Nothing
+ opFA n = OpCodes.OpInstanceMigrate iname True False True (lookNode n)
opR n = OpCodes.OpInstanceReplaceDisks iname (lookNode n)
OpCodes.ReplaceNewSecondary [] Nothing
in case move of
Failover -> [ opF ]
+ FailoverToAny np -> [ opFA np ]
ReplacePrimary np -> [ opF, opR np, opF ]
ReplaceSecondary ns -> [ opR ns ]
ReplaceAndFailover np -> [ opR np, opF ]
diff --git a/htools/Ganeti/HTools/Types.hs b/htools/Ganeti/HTools/Types.hs
index b2d2082..9db018c 100644
--- a/htools/Ganeti/HTools/Types.hs
+++ b/htools/Ganeti/HTools/Types.hs
@@ -296,6 +296,8 @@ type Placement = (Idx, Ndx, Ndx, IMove, Score)
-- | An instance move definition.
data IMove = Failover -- ^ Failover the instance (f)
+ | FailoverToAny Ndx -- ^ Failover to a random node
+ -- (fa:np), for shared storage
| ReplacePrimary Ndx -- ^ Replace primary (f, r:np, f)
| ReplaceSecondary Ndx -- ^ Replace secondary (r:ns)
| ReplaceAndFailover Ndx -- ^ Replace secondary, failover (r:np, f)
--
1.7.9.1