ganeti-htoolsSource codeContentsIndex
Ganeti.HTools.Cluster
Contents
Types
Utility functions
hbal functions
Allocation functions
Formatting functions
Node group functions
Description

Implementation of cluster-wide logic.

This module holds all pure cluster-logic; I/O related functionality goes into the Main module for the individual binaries.

Synopsis
data AllocSolution = AllocSolution {
asFailures :: [FailMode]
asAllocs :: Int
asSolutions :: [AllocElement]
asLog :: [String]
}
type AllocResult = (FailStats, List, List, [Instance], [CStats])
type AllocNodes = Either [Ndx] [(Ndx, Ndx)]
emptySolution :: AllocSolution
data Table = Table List List Score [Placement]
data CStats = CStats {
csFmem :: Int
csFdsk :: Int
csAmem :: Int
csAdsk :: Int
csAcpu :: Int
csMmem :: Int
csMdsk :: Int
csMcpu :: Int
csImem :: Int
csIdsk :: Int
csIcpu :: Int
csTmem :: Double
csTdsk :: Double
csTcpu :: Double
csVcpu :: Int
csXmem :: Int
csNmem :: Int
csScore :: Score
csNinst :: Int
}
type AllocStats = (RSpec, RSpec, RSpec)
verifyN1 :: [Node] -> [Node]
computeBadItems :: List -> List -> ([Node], [Instance])
emptyCStats :: CStats
updateCStats :: CStats -> Node -> CStats
totalResources :: List -> CStats
computeAllocationDelta :: CStats -> CStats -> AllocStats
detailedCVInfo :: [(Double, String)]
detailedCVWeights :: [Double]
compDetailedCV :: List -> [Double]
compCV :: List -> Double
getOnline :: List -> [Node]
compareTables :: Table -> Table -> Table
applyMove :: List -> Instance -> IMove -> OpResult (List, Instance, Ndx, Ndx)
allocateOnSingle :: List -> Instance -> Ndx -> OpResult AllocElement
allocateOnPair :: List -> Instance -> Ndx -> Ndx -> OpResult AllocElement
checkSingleStep :: Table -> Instance -> Table -> IMove -> Table
possibleMoves :: Bool -> Ndx -> [IMove]
checkInstanceMove :: [Ndx] -> Bool -> Table -> Instance -> Table
checkMove :: [Ndx] -> Bool -> Table -> [Instance] -> Table
doNextBalance :: Table -> Int -> Score -> Bool
tryBalance :: Table -> Bool -> Bool -> Score -> Score -> Maybe Table
collapseFailures :: [FailMode] -> FailStats
concatAllocs :: AllocSolution -> OpResult AllocElement -> AllocSolution
sumAllocs :: AllocSolution -> AllocSolution -> AllocSolution
describeSolution :: AllocSolution -> String
annotateSolution :: AllocSolution -> AllocSolution
genAllocNodes :: List -> List -> Int -> Bool -> Result AllocNodes
tryAlloc :: Monad m => List -> List -> Instance -> AllocNodes -> m AllocSolution
solutionDescription :: List -> (Gdx, Result AllocSolution) -> [String]
filterMGResults :: List -> [(Gdx, Result AllocSolution)] -> [(Gdx, AllocSolution)]
sortMGResults :: List -> [(Gdx, AllocSolution)] -> [(Gdx, AllocSolution)]
tryMGAlloc :: List -> List -> List -> Instance -> Int -> Result AllocSolution
tryReloc :: Monad m => List -> List -> Idx -> Int -> [Ndx] -> m AllocSolution
tryMGReloc :: Monad m => List -> List -> List -> Idx -> Int -> [Ndx] -> m AllocSolution
evacInstance :: Monad m => [Ndx] -> List -> (List, AllocSolution) -> Idx -> m (List, AllocSolution)
tryEvac :: Monad m => List -> List -> [Idx] -> [Ndx] -> m AllocSolution
tryMGEvac :: Monad m => List -> List -> List -> [Ndx] -> m AllocSolution
iterateAlloc :: List -> List -> Instance -> AllocNodes -> [Instance] -> [CStats] -> Result AllocResult
tieredAlloc :: List -> List -> Instance -> AllocNodes -> [Instance] -> [CStats] -> Result AllocResult
tieredSpecMap :: [Instance] -> [String]
computeMoves :: Instance -> String -> IMove -> String -> String -> (String, [String])
printSolutionLine :: List -> List -> Int -> Int -> Placement -> Int -> (String, [String])
involvedNodes :: List -> Placement -> [Ndx]
mergeJobs :: ([JobSet], [Ndx]) -> MoveJob -> ([JobSet], [Ndx])
splitJobs :: [MoveJob] -> [JobSet]
formatJob :: Int -> Int -> (Int, MoveJob) -> [String]
formatCmds :: [JobSet] -> String
printNodes :: List -> [String] -> String
printInsts :: List -> List -> String
printStats :: List -> String
iMoveToJob :: List -> List -> Idx -> IMove -> [OpCode]
instanceGroup :: List -> Instance -> Result Gdx
instancePriGroup :: List -> Instance -> Gdx
findSplitInstances :: List -> List -> [Instance]
splitCluster :: List -> List -> [(Gdx, (List, List))]
Types
data AllocSolution Source
Allocation/relocation solution.
Constructors
AllocSolution
asFailures :: [FailMode]Failure counts
asAllocs :: IntGood allocation count
asSolutions :: [AllocElement]The actual result, length of the list depends on the allocation/relocation mode
asLog :: [String]A list of informational messages
type AllocResult = (FailStats, List, List, [Instance], [CStats])Source
Allocation results, as used in iterateAlloc and tieredAlloc.
type AllocNodes = Either [Ndx] [(Ndx, Ndx)]Source
A type denoting the valid allocation mode/pairs. For a one-node allocation, this will be a Left [Node], whereas for a two-node allocation, this will be a Right [(Node, Node)].
emptySolution :: AllocSolutionSource
The empty solution we start with when computing allocations
data Table Source
The complete state for the balancing solution
Constructors
Table List List Score [Placement]
data CStats Source
Constructors
CStats
csFmem :: IntCluster free mem
csFdsk :: IntCluster free disk
csAmem :: IntCluster allocatable mem
csAdsk :: IntCluster allocatable disk
csAcpu :: IntCluster allocatable cpus
csMmem :: IntMax node allocatable mem
csMdsk :: IntMax node allocatable disk
csMcpu :: IntMax node allocatable cpu
csImem :: IntInstance used mem
csIdsk :: IntInstance used disk
csIcpu :: IntInstance used cpu
csTmem :: DoubleCluster total mem
csTdsk :: DoubleCluster total disk
csTcpu :: DoubleCluster total cpus
csVcpu :: IntCluster virtual cpus (if node pCpu has been set, otherwise -1)
csXmem :: IntUnnacounted for mem
csNmem :: IntNode own memory
csScore :: ScoreThe cluster score
csNinst :: IntThe total number of instances
type AllocStats = (RSpec, RSpec, RSpec)Source
Currently used, possibly to allocate, unallocable
Utility functions
verifyN1 :: [Node] -> [Node]Source
Verifies the N+1 status and return the affected nodes.
computeBadItems :: List -> List -> ([Node], [Instance])Source

Computes the pair of bad nodes and instances.

The bad node list is computed via a simple verifyN1 check, and the bad instance list is the list of primary and secondary instances of those nodes.

emptyCStats :: CStatsSource
Zero-initializer for the CStats type
updateCStats :: CStats -> Node -> CStatsSource
Update stats with data from a new node
totalResources :: List -> CStatsSource
Compute the total free disk and memory in the cluster.
computeAllocationDelta :: CStats -> CStats -> AllocStatsSource

Compute the delta between two cluster state.

This is used when doing allocations, to understand better the available cluster resources. The return value is a triple of the current used values, the delta that was still allocated, and what was left unallocated.

detailedCVInfo :: [(Double, String)]Source
The names and weights of the individual elements in the CV list
detailedCVWeights :: [Double]Source
compDetailedCV :: List -> [Double]Source
Compute the mem and disk covariance.
compCV :: List -> DoubleSource
Compute the total variance.
getOnline :: List -> [Node]Source
Compute online nodes from a Node.List
hbal functions
compareTables :: Table -> Table -> TableSource
Compute best table. Note that the ordering of the arguments is important.
applyMove :: List -> Instance -> IMove -> OpResult (List, Instance, Ndx, Ndx)Source
Applies an instance move to a given node list and instance.
allocateOnSingle :: List -> Instance -> Ndx -> OpResult AllocElementSource
Tries to allocate an instance on one given node.
allocateOnPair :: List -> Instance -> Ndx -> Ndx -> OpResult AllocElementSource
Tries to allocate an instance on a given pair of nodes.
checkSingleStepSource
:: TableThe original table
-> InstanceThe instance to move
-> TableThe current best table
-> IMoveThe move to apply
-> TableThe final best table
Tries to perform an instance move and returns the best table between the original one and the new one.
possibleMovesSource
:: BoolWhether the secondary node is a valid new node
-> NdxTarget node candidate
-> [IMove]List of valid result moves
Given the status of the current secondary as a valid new node and the current candidate target node, generate the possible moves for a instance.
checkInstanceMoveSource
:: [Ndx]Allowed target node indices
-> BoolWhether disk moves are allowed
-> TableOriginal table
-> InstanceInstance to move
-> TableBest new table for this instance
Compute the best move for a given instance.
checkMoveSource
:: [Ndx]Allowed target node indices
-> BoolWhether disk moves are allowed
-> TableThe current solution
-> [Instance]List of instances still to move
-> TableThe new solution
Compute the best next move.
doNextBalanceSource
:: TableThe starting table
-> IntRemaining length
-> ScoreScore at which to stop
-> BoolThe resulting table and commands
Check if we are allowed to go deeper in the balancing
tryBalanceSource
:: TableThe starting table
-> BoolAllow disk moves
-> BoolOnly evacuate moves
-> ScoreMin gain threshold
-> ScoreMin gain
-> Maybe TableThe resulting table and commands
Run a balance move
Allocation functions
collapseFailures :: [FailMode] -> FailStatsSource
Build failure stats out of a list of failures
concatAllocs :: AllocSolution -> OpResult AllocElement -> AllocSolutionSource
Update current Allocation solution and failure stats with new elements
sumAllocs :: AllocSolution -> AllocSolution -> AllocSolutionSource
Sums two allocation solutions (e.g. for two separate node groups).
describeSolution :: AllocSolution -> StringSource
Given a solution, generates a reasonable description for it
annotateSolution :: AllocSolution -> AllocSolutionSource
Annotates a solution with the appropriate string
genAllocNodesSource
:: ListGroup list
-> ListThe node map
-> IntThe number of nodes required
-> BoolWhether to drop or not unallocable nodes
-> Result AllocNodesThe (monadic) result
Generate the valid node allocation singles or pairs for a new instance.
tryAllocSource
:: Monad m
=> ListThe instance list
-> ListThe instance to allocate
-> InstanceThe allocation targets
-> AllocNodesPossible solution list
-> m AllocSolution
Try to allocate an instance on the cluster.
solutionDescription :: List -> (Gdx, Result AllocSolution) -> [String]Source
Given a group/result, describe it as a nice (list of) messages
filterMGResults :: List -> [(Gdx, Result AllocSolution)] -> [(Gdx, AllocSolution)]Source
From a list of possibly bad and possibly empty solutions, filter only the groups with a valid result
sortMGResults :: List -> [(Gdx, AllocSolution)] -> [(Gdx, AllocSolution)]Source
Sort multigroup results based on policy and score
tryMGAllocSource
:: ListThe group list
-> ListThe node list
-> ListThe instance list
-> InstanceThe instance to allocate
-> IntRequired number of nodes
-> Result AllocSolutionPossible solution list
Try to allocate an instance on a multi-group cluster.
tryRelocSource
:: Monad m
=> ListThe instance list
-> ListThe index of the instance to move
-> IdxThe number of nodes required
-> IntNodes which should not be used
-> [Ndx]Solution list
-> m AllocSolution
Try to relocate an instance on the cluster.
tryMGRelocSource
:: Monad m
=> ListThe node list
-> ListThe instance list
-> ListThe index of the instance to move
-> IdxThe number of nodes required
-> IntNodes which should not be used
-> [Ndx]Solution list
-> m AllocSolution
evacInstanceSource
:: Monad m
=> [Ndx]The current instance list
-> ListThe current state
-> (List, AllocSolution)The instance to evacuate
-> Idx
-> m (List, AllocSolution)
Change an instance's secondary node
tryEvacSource
:: Monad m
=> ListThe instance list
-> ListInstances to be evacuated
-> [Idx]Restricted nodes (the ones being evacuated)
-> [Ndx]Solution list
-> m AllocSolution
Try to evacuate a list of nodes.
tryMGEvacSource
:: Monad m
=> ListThe node list
-> ListThe instance list
-> ListNodes to be evacuated
-> [Ndx]Solution list
-> m AllocSolution
Multi-group evacuation of a list of nodes.
iterateAlloc :: List -> List -> Instance -> AllocNodes -> [Instance] -> [CStats] -> Result AllocResultSource
Recursively place instances on the cluster until we're out of space
tieredAlloc :: List -> List -> Instance -> AllocNodes -> [Instance] -> [CStats] -> Result AllocResultSource
The core of the tiered allocation mode
tieredSpecMap :: [Instance] -> [String]Source
Compute the tiered spec string description from a list of allocated instances.
Formatting functions
computeMovesSource
:: InstanceThe instance to be moved
-> StringThe instance name
-> IMoveThe move being performed
-> StringNew primary
-> StringNew secondary
-> (String, [String])Tuple of moves and commands list; moves is containing either f for failover or r:name for replace secondary, while the command list holds gnt-instance commands (without that prefix), e.g "failover instance1"
Given the original and final nodes, computes the relocation description.
printSolutionLineSource
:: ListThe node list
-> ListThe instance list
-> IntMaximum node name length
-> IntMaximum instance name length
-> PlacementThe current placement
-> IntThe index of the placement in the solution
-> (String, [String])
Converts a placement to string format.
involvedNodes :: List -> Placement -> [Ndx]Source
Return the instance and involved nodes in an instance move.
mergeJobs :: ([JobSet], [Ndx]) -> MoveJob -> ([JobSet], [Ndx])Source
Inner function for splitJobs, that either appends the next job to the current jobset, or starts a new jobset.
splitJobs :: [MoveJob] -> [JobSet]Source
Break a list of moves into independent groups. Note that this will reverse the order of jobs.
formatJob :: Int -> Int -> (Int, MoveJob) -> [String]Source
Given a list of commands, prefix them with gnt-instance and also beautify the display a little.
formatCmds :: [JobSet] -> StringSource
Given a list of commands, prefix them with gnt-instance and also beautify the display a little.
printNodes :: List -> [String] -> StringSource
Print the node list.
printInsts :: List -> List -> StringSource
Print the instance list.
printStats :: List -> StringSource
Shows statistics for a given node list.
iMoveToJob :: List -> List -> Idx -> IMove -> [OpCode]Source
Convert a placement into a list of OpCodes (basically a job).
Node group functions
instanceGroup :: List -> Instance -> Result GdxSource
Computes the group of an instance
instancePriGroup :: List -> Instance -> GdxSource
Computes the group of an instance per the primary node
findSplitInstances :: List -> List -> [Instance]Source
Compute the list of badly allocated instances (split across node groups)
splitCluster :: List -> List -> [(Gdx, (List, List))]Source
Splits a cluster into the component node groups
Produced by Haddock version 2.6.0