Commit 7eda951b authored by Iustin Pop's avatar Iustin Pop

Add a type synonym for the allocation function sig

Both iterateAlloc and tieredAlloc share the same signature, but it's
not documented nor exported (needed for refactoring).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent d12f50b2
......@@ -34,6 +34,7 @@ module Ganeti.HTools.Cluster
, Table(..)
, CStats(..)
, AllocStats
, AllocMethod
-- * Generic functions
, totalResources
, computeAllocationDelta
......@@ -165,6 +166,16 @@ data CStats = CStats { csFmem :: Integer -- ^ Cluster free mem
-- | Currently used, possibly to allocate, unallocable.
type AllocStats = (RSpec, RSpec, RSpec)
-- | A simple type for allocation functions.
type AllocMethod = Node.List -- ^ Node list
-> Instance.List -- ^ Instance list
-> Maybe Int -- ^ Optional allocation limit
-> Instance.Instance -- ^ Instance spec for allocation
-> AllocNodes -- ^ Which nodes we should allocate on
-> [Instance.Instance] -- ^ Allocated instances
-> [CStats] -- ^ Running cluster stats
-> Result AllocResult -- ^ Allocation result
-- * Utility functions
-- | Verifies the N+1 status and return the affected nodes.
......@@ -1145,15 +1156,12 @@ tryChangeGroup gl ini_nl ini_il gdxs idxs =
(map (`Container.find` ini_il) idxs)
in return (fin_nl, fin_il, reverseEvacSolution esol)
-- | Recursively place instances on the cluster until we're out of space.
iterateAlloc :: Node.List
-> Instance.List
-> Maybe Int
-> Instance.Instance
-> AllocNodes
-> [Instance.Instance]
-> [CStats]
-> Result AllocResult
-- | Standard-sized allocation method.
--
-- This places instances of the same size on the cluster until we're
-- out of space. The result will be a list of identically-sized
-- instances.
iterateAlloc :: AllocMethod
iterateAlloc nl il limit newinst allocnodes ixes cstats =
let depth = length ixes
newname = printf "new-%d" depth::String
......@@ -1173,15 +1181,12 @@ iterateAlloc nl il limit newinst allocnodes ixes cstats =
newlimit newinst allocnodes (xi:ixes)
(totalResources xnl:cstats)
-- | The core of the tiered allocation mode.
tieredAlloc :: Node.List
-> Instance.List
-> Maybe Int
-> Instance.Instance
-> AllocNodes
-> [Instance.Instance]
-> [CStats]
-> Result AllocResult
-- | Tiered allocation method.
--
-- This places instances on the cluster, and decreases the spec until
-- we can allocate again. The result will be a list of decreasing
-- instance specs.
tieredAlloc :: AllocMethod
tieredAlloc nl il limit newinst allocnodes ixes cstats =
case iterateAlloc nl il limit newinst allocnodes ixes cstats of
Bad s -> Bad s
......
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