Commit 6d0bc5ca authored by Iustin Pop's avatar Iustin Pop
Browse files

Prevent allocation on unallocable node groups



This patch changes genAllocNodes so that it also takes the group list,
using it to filter out any nodes which live on unallocable groups.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAdeodato Simo <dato@google.com>
parent 7af6975a
......@@ -623,11 +623,18 @@ annotateSolution :: AllocSolution -> AllocSolution
annotateSolution as = as { asLog = describeSolution as : asLog as }
-- | Generate the valid node allocation singles or pairs for a new instance.
genAllocNodes :: Node.List -- ^ The node map
genAllocNodes :: Group.List -- ^ Group list
-> Node.List -- ^ The node map
-> Int -- ^ The number of nodes required
-> Bool -- ^ Whether to drop or not
-- unallocable nodes
-> Result AllocNodes -- ^ The (monadic) result
genAllocNodes nl count =
let all_nodes = getOnline nl
genAllocNodes gl nl count drop_unalloc =
let filter_fn = if drop_unalloc
then filter ((/=) AllocUnallocable . Group.allocPolicy .
flip Container.find gl . Node.group)
else id
all_nodes = filter_fn $ getOnline nl
all_pairs = liftM2 (,) all_nodes all_nodes
ok_pairs = filter (\(x, y) -> Node.idx x /= Node.idx y &&
Node.group x == Node.group y) all_pairs
......@@ -703,7 +710,8 @@ tryMGAlloc mggl mgnl mgil inst cnt =
let groups = splitCluster mgnl mgil
-- TODO: currently we consider all groups preferred
sols = map (\(gid, (nl, il)) ->
(gid, genAllocNodes nl cnt >>= tryAlloc nl il inst))
(gid, genAllocNodes mggl nl cnt False >>=
tryAlloc nl il inst))
groups::[(Gdx, Result AllocSolution)]
all_msgs = concatMap (solutionDescription mggl) sols
goodSols = filterMGResults mggl sols
......
......@@ -684,7 +684,8 @@ prop_ClusterAlloc_sane node inst =
let nl = makeSmallCluster node count
il = Container.empty
inst' = setInstanceSmallerThanNode node inst
in case Cluster.genAllocNodes nl 2 >>= Cluster.tryAlloc nl il inst' of
in case Cluster.genAllocNodes defGroupList nl 2 True >>=
Cluster.tryAlloc nl il inst' of
Types.Bad _ -> False
Types.Ok as ->
case Cluster.asSolutions as of
......@@ -707,7 +708,7 @@ prop_ClusterCanTieredAlloc node inst =
==>
let nl = makeSmallCluster node count
il = Container.empty
allocnodes = Cluster.genAllocNodes nl rqnodes
allocnodes = Cluster.genAllocNodes defGroupList nl rqnodes True
in case allocnodes >>= \allocnodes' ->
Cluster.tieredAlloc nl il inst allocnodes' [] [] of
Types.Bad _ -> False
......@@ -726,7 +727,8 @@ prop_ClusterAllocEvac node inst =
let nl = makeSmallCluster node count
il = Container.empty
inst' = setInstanceSmallerThanNode node inst
in case Cluster.genAllocNodes nl 2 >>= Cluster.tryAlloc nl il inst' of
in case Cluster.genAllocNodes defGroupList nl 2 True >>=
Cluster.tryAlloc nl il inst' of
Types.Bad _ -> False
Types.Ok as ->
case Cluster.asSolutions as of
......@@ -751,7 +753,7 @@ prop_ClusterAllocBalance node =
let nl = makeSmallCluster node count
(hnode, nl') = IntMap.deleteFindMax nl
il = Container.empty
allocnodes = Cluster.genAllocNodes nl' 2
allocnodes = Cluster.genAllocNodes defGroupList nl' 2 True
i_templ = createInstance Types.unitMem Types.unitDsk Types.unitCpu
in case allocnodes >>= \allocnodes' ->
Cluster.iterateAlloc nl' il i_templ allocnodes' [] [] of
......
......@@ -290,7 +290,7 @@ main = do
let reqinst = iofspec ispec
allocnodes <- exitifbad $ Cluster.genAllocNodes nl req_nodes
allocnodes <- exitifbad $ Cluster.genAllocNodes gl nl req_nodes True
-- Run the tiered allocation, if enabled
......
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