Commit c9a9b853 authored by Iustin Pop's avatar Iustin Pop
Browse files

htools: generalise and rename availableLocalNodes



Currently this function works in the context of an instance, computing
its local group nodes. We can use generalise it to take a group index
argument, so that it's not bound to an instance, and we rename it
accordingly.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 57f07ff2
...@@ -1033,15 +1033,14 @@ evacDrbdSecondaryInner nl inst gdx accu ndx = ...@@ -1033,15 +1033,14 @@ evacDrbdSecondaryInner nl inst gdx accu ndx =
then accu then accu
else new_accu else new_accu
-- | Computes the local nodes of a given instance which are available -- | Computes the nodes in a given group which are available for
-- for allocation. -- allocation.
availableLocalNodes :: Node.List availableGroupNodes :: [(Gdx, [Ndx])] -- ^ Group index/node index assoc list
-> [(Gdx, [Ndx])] -> IntSet.IntSet -- ^ Nodes that are excluded
-> IntSet.IntSet -> Gdx -- ^ The group for which we
-> Instance.Instance -- query the nodes
-> Result [Ndx] -> Result [Ndx] -- ^ List of available node indices
availableLocalNodes nl group_nodes excl_ndx inst = do availableGroupNodes group_nodes excl_ndx gdx = do
let gdx = instancePriGroup nl inst
local_nodes <- maybe (Bad $ "Can't find group with index " ++ show gdx) local_nodes <- maybe (Bad $ "Can't find group with index " ++ show gdx)
Ok (lookup gdx group_nodes) Ok (lookup gdx group_nodes)
let avail_nodes = filter (not . flip IntSet.member excl_ndx) local_nodes let avail_nodes = filter (not . flip IntSet.member excl_ndx) local_nodes
...@@ -1076,7 +1075,8 @@ tryNodeEvac _ ini_nl ini_il mode idxs = ...@@ -1076,7 +1075,8 @@ tryNodeEvac _ ini_nl ini_il mode idxs =
(_, _, esol) = (_, _, esol) =
foldl' (\state@(nl, il, _) inst -> foldl' (\state@(nl, il, _) inst ->
updateEvacSolution state inst $ updateEvacSolution state inst $
availableLocalNodes nl group_ndx excl_ndx inst >>= availableGroupNodes group_ndx
excl_ndx (instancePriGroup nl inst) >>=
nodeEvacInstance nl il mode inst nodeEvacInstance nl il mode inst
) )
(ini_nl, ini_il, emptyEvacSolution) (ini_nl, ini_il, emptyEvacSolution)
......
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