Commit 6804faa0 authored by Iustin Pop's avatar Iustin Pop
Browse files

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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 7073b3a8
......@@ -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
......
......@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Ganeti.HTools.IAlloc
( readRequest
, runIAllocator
, processRelocate
) where
import Data.Either ()
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment