diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs index 27017b25da740cc513e0a8fd367df6046107f7b7..3d1b9f23fc87ef72e39c4b46cb584efab5161340 100644 --- a/htools/Ganeti/HTools/Cluster.hs +++ b/htools/Ganeti/HTools/Cluster.hs @@ -61,7 +61,6 @@ module Ganeti.HTools.Cluster , tryAlloc , tryMGAlloc , tryReloc - , tryEvac , tryNodeEvac , tryChangeGroup , collapseFailures @@ -811,45 +810,6 @@ tryReloc _ _ _ reqn _ = fail $ "Unsupported number of relocation \ \destinations required (" ++ show reqn ++ "), only one supported" --- | Change an instance's secondary node. -evacInstance :: (Monad m) => - [Ndx] -- ^ Excluded nodes - -> Instance.List -- ^ The current instance list - -> (Node.List, AllocSolution) -- ^ The current state - -> Idx -- ^ The instance to evacuate - -> m (Node.List, AllocSolution) -evacInstance ex_ndx il (nl, old_as) idx = do - -- FIXME: hardcoded one node here - - -- Longer explanation: evacuation is currently hardcoded to DRBD - -- instances (which have one secondary); hence, even if the - -- IAllocator protocol can request N nodes for an instance, and all - -- the message parsing/loading pass this, this implementation only - -- supports one; this situation needs to be revisited if we ever - -- support more than one secondary, or if we change the storage - -- model - new_as <- tryReloc nl il idx 1 ex_ndx - case asSolutions new_as of - -- an individual relocation succeeded, we kind of compose the data - -- from the two solutions - csol@(nl', _, _, _):_ -> - return (nl', new_as { asSolutions = csol:asSolutions old_as }) - -- this relocation failed, so we fail the entire evac - _ -> fail $ "Can't evacuate instance " ++ - Instance.name (Container.find idx il) ++ - ": " ++ describeSolution new_as - --- | Try to evacuate a list of nodes. -tryEvac :: (Monad m) => - Node.List -- ^ The node list - -> Instance.List -- ^ The instance list - -> [Idx] -- ^ Instances to be evacuated - -> [Ndx] -- ^ Restricted nodes (the ones being evacuated) - -> m AllocSolution -- ^ Solution list -tryEvac nl il idxs ex_ndx = do - (_, sol) <- foldM (evacInstance ex_ndx il) (nl, emptyAllocSolution) idxs - return sol - -- | Function which fails if the requested mode is change secondary. -- -- This is useful since except DRBD, no other disk template can diff --git a/htools/Ganeti/HTools/IAlloc.hs b/htools/Ganeti/HTools/IAlloc.hs index 91b37066f849a121793da5f41fadfb2124eb67f3..aabdd76f902b2523054454e7780cdeae3c546b43 100644 --- a/htools/Ganeti/HTools/IAlloc.hs +++ b/htools/Ganeti/HTools/IAlloc.hs @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA module Ganeti.HTools.IAlloc ( readRequest , runIAllocator + , processRelocate ) where import Data.Either () diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs index 80551ebb74541291f5de2deb05ea2413ec8e53d2..305a2bee7e7114f7a229feb5d132e6ca587b963c 100644 --- a/htools/Ganeti/HTools/QC.hs +++ b/htools/Ganeti/HTools/QC.hs @@ -908,8 +908,9 @@ prop_ClusterAllocEvac node inst = (xnl, xi, _, _):[] -> let sdx = Instance.sNode xi il' = Container.add (Instance.idx xi) xi il - in case Cluster.tryEvac xnl il' [Instance.idx xi] [sdx] of - Just _ -> True + in case IAlloc.processRelocate defGroupList xnl il' + (Instance.idx xi) 1 [sdx] of + Types.Ok _ -> True _ -> False _ -> False