--- | Recursively place instances on the cluster until we're out of space
-iterateDepth :: Node.List
- -> Instance.List
- -> Instance.Instance
- -> Int
- -> [Instance.Instance]
- -> Result (FailStats, Node.List, [Instance.Instance])
-iterateDepth nl il newinst nreq ixes =
- let depth = length ixes
- newname = printf "new-%d" depth::String
- newidx = length (Container.elems il) + depth
- newi2 = Instance.setIdx (Instance.setName newinst newname) newidx
- in case Cluster.tryAlloc nl il newi2 nreq of
- Bad s -> Bad s
- Ok (errs, _, sols3) ->
- case sols3 of
- Nothing -> Ok (Cluster.collapseFailures errs, nl, ixes)
- Just (_, (xnl, xi, _)) ->
- iterateDepth xnl il newinst nreq $! (xi:ixes)
-
-tieredAlloc :: Node.List
- -> Instance.List
- -> Instance.Instance
- -> Int
- -> [Instance.Instance]
- -> Result (FailStats, Node.List, [Instance.Instance])
-tieredAlloc nl il newinst nreq ixes =
- case iterateDepth nl il newinst nreq ixes of
- Bad s -> Bad s
- Ok (errs, nl', ixes') ->
- case Instance.shrinkByType newinst . fst . last $
- sortBy (compare `on` snd) errs of
- Bad _ -> Ok (errs, nl', ixes')
- Ok newinst' ->
- tieredAlloc nl' il newinst' nreq ixes'
-
-