From 6804faa032e855304dec3dd5d264237722ebcd16 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 14 Sep 2011 12:58:18 +0200 Subject: [PATCH] htools: remove dead code The tryEvac/evacuateInstance functions are no longer used in the new multi-group world order, so we remove them and change the unit-test to test the actual IAllocator function. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- htools/Ganeti/HTools/Cluster.hs | 40 --------------------------------- htools/Ganeti/HTools/IAlloc.hs | 1 + htools/Ganeti/HTools/QC.hs | 5 +++-- 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs index 27017b25d..3d1b9f23f 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 91b37066f..aabdd76f9 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 80551ebb7..305a2bee7 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 -- GitLab