Skip to content
Snippets Groups Projects
Commit 8c2ebac8 authored by Iustin Pop's avatar Iustin Pop
Browse files

hail: do not allocate on offline/drained nodes

This patch implements filtering out of the offline/drained nodes and
fixes a bug in IAllocator.hs parsing (similar to an older bug in Rapi.hs
from where the code was copied).
parent 842e3764
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ parseNode n a = do
dtotal <- fromObj "total_disk" a
dfree <- fromObj "free_disk" a
offline <- fromObj "offline" a
drained <- fromObj "offline" a
drained <- fromObj "drained" a
return $ (name, Node.create n mtotal mnode mfree dtotal dfree
(offline || drained))
......
......@@ -51,6 +51,10 @@ options =
"show help"
]
-- | Compute online nodes from a NodeList
getOnline :: NodeList -> [Node.Node]
getOnline = filter (not . Node.offline) . Container.elems
-- | Try to allocate an instance on the cluster
tryAlloc :: (Monad m) =>
NodeList
......@@ -59,7 +63,7 @@ tryAlloc :: (Monad m) =>
-> Int
-> m [(Maybe NodeList, [Node.Node])]
tryAlloc nl _ inst 2 =
let all_nodes = Container.elems nl
let all_nodes = getOnline nl
all_pairs = liftM2 (,) all_nodes all_nodes
ok_pairs = filter (\(x, y) -> Node.idx x /= Node.idx y) all_pairs
sols = map (\(p, s) ->
......@@ -68,7 +72,7 @@ tryAlloc nl _ inst 2 =
in return sols
tryAlloc nl _ inst 1 =
let all_nodes = Container.elems nl
let all_nodes = getOnline nl
sols = map (\p -> (fst $ Cluster.allocateOnSingle nl inst p, [p]))
all_nodes
in return sols
......@@ -86,7 +90,7 @@ tryReloc :: (Monad m) =>
-> [Int]
-> m [(Maybe NodeList, [Node.Node])]
tryReloc nl il xid 1 ex_idx =
let all_nodes = Container.elems nl
let all_nodes = getOnline nl
inst = Container.find xid il
valid_nodes = filter (not . flip elem ex_idx . idx) all_nodes
valid_idxes = map Node.idx valid_nodes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment