Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ganeti.HTools.Node
Description
Module describing a node.
All updates are functional (copy-based) and return a new node with updated value.
Synopsis
- data Node = Node {
- name :: String
- alias :: String
- tMem :: Double
- nMem :: Int
- iMem :: Int
- fMem :: Int
- fMemForth :: Int
- xMem :: Int
- tDsk :: Double
- fDsk :: Int
- fDskForth :: Int
- tCpu :: Double
- tCpuSpeed :: Double
- nCpu :: Int
- uCpu :: Int
- uCpuForth :: Int
- tSpindles :: Int
- fSpindles :: Int
- fSpindlesForth :: Int
- pList :: [Idx]
- pListForth :: [Idx]
- sList :: [Idx]
- sListForth :: [Idx]
- idx :: Ndx
- peers :: PeerMap
- failN1 :: Bool
- failN1Forth :: Bool
- rMem :: Int
- rMemForth :: Int
- pMem :: Double
- pMemForth :: Double
- pDsk :: Double
- pDskForth :: Double
- pRem :: Double
- pRemForth :: Double
- pCpu :: Double
- pCpuForth :: Double
- mDsk :: Double
- loDsk :: Int
- hiCpu :: Int
- hiSpindles :: Double
- instSpindles :: Double
- instSpindlesForth :: Double
- offline :: Bool
- isMaster :: Bool
- nTags :: [String]
- utilPool :: DynUtil
- utilLoad :: DynUtil
- utilLoadForth :: DynUtil
- pTags :: TagMap
- group :: Gdx
- iPolicy :: IPolicy
- exclStorage :: Bool
- migTags :: Set String
- rmigTags :: Set String
- locationTags :: Set String
- locationScore :: Int
- instanceMap :: Map (String, String) Int
- hypervisor :: Maybe Hypervisor
- type List = Container Node
- pCpuEff :: Node -> Double
- pCpuEffForth :: Node -> Double
- create :: String -> Double -> Int -> Int -> Double -> Int -> Double -> Int -> Bool -> Int -> Int -> Gdx -> Bool -> Node
- buildPeers :: Node -> List -> Node
- setIdx :: Node -> Ndx -> Node
- setAlias :: Node -> String -> Node
- setOffline :: Node -> Bool -> Node
- setPri :: Node -> Instance -> Node
- calcFmemOfflineOrForthcoming :: Node -> Container Instance -> Int
- setSec :: Node -> Instance -> Node
- setMaster :: Node -> Bool -> Node
- setNodeTags :: Node -> [String] -> Node
- setMdsk :: Node -> Double -> Node
- setMcpu :: Node -> Double -> Node
- setPolicy :: IPolicy -> Node -> Node
- setCpuSpeed :: Node -> Double -> Node
- setMigrationTags :: Node -> Set String -> Node
- setRecvMigrationTags :: Node -> Set String -> Node
- setLocationTags :: Node -> Set String -> Node
- setHypervisor :: Node -> Hypervisor -> Node
- addTags :: Ord k => Map k Int -> [k] -> Map k Int
- delTags :: Ord k => Map k Int -> [k] -> Map k Int
- rejectAddTags :: TagMap -> [String] -> Bool
- getPolicyHealth :: Node -> OpResult ()
- removePri :: Node -> Instance -> Node
- removeSec :: Node -> Instance -> Node
- addPri :: Node -> Instance -> OpResult Node
- addPriEx :: Bool -> Node -> Instance -> OpResult Node
- addSec :: Node -> Instance -> Ndx -> OpResult Node
- addSecEx :: Bool -> Node -> Instance -> Ndx -> OpResult Node
- addSecExEx :: Bool -> Bool -> Node -> Instance -> Ndx -> OpResult Node
- checkMigration :: Node -> Node -> OpResult ()
- availDisk :: Node -> Int
- availMem :: Node -> Int
- missingMem :: Node -> Int
- unallocatedMem :: Node -> Int
- recordedFreeMem :: Node -> Int
- availCpu :: Node -> Int
- iDsk :: Node -> Int
- conflictingPrimaries :: Node -> Int
- genPowerOnOpCodes :: MonadFail m => [Node] -> m [OpCode]
- genPowerOffOpCodes :: MonadFail m => [Node] -> m [OpCode]
- genAddTagsOpCode :: Node -> [String] -> OpCode
- defaultFields :: [String]
- showHeader :: String -> (String, Bool)
- showField :: Node -> String -> String
- list :: [String] -> Node -> [String]
- type AssocList = [(Ndx, Node)]
- noSecondary :: Ndx
- computeGroups :: [Node] -> [(Gdx, [Node])]
- mkNodeGraph :: List -> List -> Maybe Graph
- mkRebootNodeGraph :: List -> List -> List -> Maybe Graph
- haveExclStorage :: List -> Bool
Documentation
The node type.
Constructors
Node | |
Fields
|
Derived parameter: ratio of virutal to physical CPUs, weighted by CPU speed.
pCpuEffForth :: Node -> Double #
Derived parameter: ratio of virutal to physical CPUs, weighted by CPU speed and taking forthcoming instances into account.
Constructor
create :: String -> Double -> Int -> Int -> Double -> Int -> Double -> Int -> Bool -> Int -> Int -> Gdx -> Bool -> Node #
Create a new node.
The index and the peers maps are empty, and will be need to be
update later via the setIdx
and buildPeers
functions.
Finalization after data loading
buildPeers :: Node -> List -> Node #
Builds the peer map for a given node.
setIdx :: Node -> Ndx -> Node #
Changes the index.
This is used only during the building of the data structures.
setAlias :: Node -> String -> Node #
Changes the alias.
This is used only during the building of the data structures.
setOffline :: Node -> Bool -> Node #
Sets the offline attribute.
setPri :: Node -> Instance -> Node #
Assigns an instance to a node as primary and update the used VCPU count, utilisation data, tags map and desired location score.
calcFmemOfflineOrForthcoming :: Node -> Container Instance -> Int #
setSec :: Node -> Instance -> Node #
Assigns an instance to a node as secondary and updates disk utilisation.
setNodeTags :: Node -> [String] -> Node #
Sets the node tags attribute
setMcpu :: Node -> Double -> Node #
Sets the max cpu usage ratio. This will update the node's ipolicy, losing sharing (but it should be a seldomly done operation).
setCpuSpeed :: Node -> Double -> Node #
Set the CPU speed
setMigrationTags :: Node -> Set String -> Node #
Set migration tags
setRecvMigrationTags :: Node -> Set String -> Node #
Set the migration tags a node is able to receive
setLocationTags :: Node -> Set String -> Node #
Set the location tags
setHypervisor :: Node -> Hypervisor -> Node #
Sets the hypervisor attribute.
Tag maps
rejectAddTags :: TagMap -> [String] -> Bool #
Check if we can add a list of tags to a tagmap.
Diagnostic commands
getPolicyHealth :: Node -> OpResult () #
For a node diagnose whether it conforms with all policies. The type is chosen to represent that of a no-op node operation.
Instance (re)location
Arguments
:: Bool | Whether to override the N+1 and other soft checks, useful if we come from a worse status (e.g. offline). If this is True, forthcoming instances may exceed available Node resources. |
-> Node | The target node |
-> Instance | The instance to add |
-> OpResult Node | The result of the operation, either the new version of the node or a failure mode |
Adds a primary instance (extended version).
addSecEx :: Bool -> Node -> Instance -> Ndx -> OpResult Node #
Adds a secondary instance (extended version).
addSecExEx :: Bool -> Bool -> Node -> Instance -> Ndx -> OpResult Node #
Adds a secondary instance (doubly extended version). The first parameter
tells addSecExEx
to ignore disks completly. There is only one legitimate
use case for this, and this is failing over a DRBD instance where the primary
node is offline (and hence will become the secondary afterwards).
checkMigration :: Node -> Node -> OpResult () #
Predicate on whether migration is supported between two nodes.
Stats
Computes the amount of available memory on a given node. Compared to unallocatedMem, this takes into account also memory reserved for secondary instances. NOTE: In case of memory overcommitment, there would be also an additional soft limit based on RAM size dedicated for instances and sum of state-of-record instance sizes (iMem): (tMem - nMem)*overcommit_ratio - iMem
missingMem :: Node -> Int #
Computes the amount of missing memory on the node. NOTE: This formula uses free memory for calculations as opposed to used_memory in the definition, that's why it is the inverse. Explanations for missing memory (+) positive, (-) negative: (+) instances are using more memory that state-of-record - on KVM this might be due to the overhead per qemu process - on Xen manually upsized domains (xen mem-set) (+) on KVM non-qemu processes might be using more memory than what is reserved for node (no isolation) (-) on KVM qemu processes allocate memory on demand, thus an instance grows over its lifetime until it reaches state-of-record (+overhead) (-) on KVM KSM might be active (-) on Xen manually downsized domains (xen mem-set)
unallocatedMem :: Node -> Int #
Computes the guaranteed
free memory, that is the minimum of what
is reported by the node (available bytes) and our calculation based on
instance sizes (our records), thus considering missing memory.
NOTE 1: During placement simulations, the recorded memory changes, as
instances are added/removed from the node, thus we have to calculate the
missingMem (correction) before altering state-of-record and then
use that correction to estimate state-of-world memory usage _after_
the placements are done rather than doing min(record, world).
NOTE 2: This is still only an approximation on KVM. As we shuffle instances
during the simulation we are considering their state-of-record size, but
in the real world the moves would shuffle parts of missing memory as well.
Unfortunately as long as we don't have a more finegrained model that can
better explain missing memory (split down based on root causes), we can't
do better.
NOTE 3: This is a hard limit based on available bytes and our bookkeeping.
In case of memory overcommitment, both recordedFreeMem and reportedFreeMem
would be extended by swap size on KVM or baloon size on Xen (their nominal
and reported values).
recordedFreeMem :: Node -> Int #
Computes state-of-record free memory on the node. | TODO: Redefine this for memory overcommitment.
conflictingPrimaries :: Node -> Int #
Check how many primary instances have conflicting tags. The algorithm to compute this is to sum the count of all tags, then subtract the size of the tag map (since each tag has at least one, non-conflicting instance); this is equivalent to summing the values in the tag map minus one.
Generate OpCodes
genPowerOnOpCodes :: MonadFail m => [Node] -> m [OpCode] #
Generate OpCode for powering on a list of nodes
genPowerOffOpCodes :: MonadFail m => [Node] -> m [OpCode] #
Generate OpCodes for powering off a list of nodes
genAddTagsOpCode :: Node -> [String] -> OpCode #
Generate OpCodes for adding tags to a node
Formatting
defaultFields :: [String] #
Constant holding the fields we're displaying by default.
showHeader :: String -> (String, Bool) #
Returns the header and numeric propery of a field.
Arguments
:: Node | Node which we're querying |
-> String | Field name |
-> String | Field value as string |
Return a field for a given node.
Misc stuff
noSecondary :: Ndx #
Constant node index for a non-moveable instance.
computeGroups :: [Node] -> [(Gdx, [Node])] #
Split a list of nodes into a list of (node group UUID, list of associated nodes).
mkNodeGraph :: List -> List -> Maybe Graph #
Transform a Node + Instance list into a NodeGraph type. Returns Nothing if the node list is empty.
mkRebootNodeGraph :: List -> List -> List -> Maybe Graph #
Transform a Nodes + Instances into a NodeGraph with all reboot exclusions. This includes edges between nodes that are the primary nodes of instances that have the same secondary node. Nodes not in the node list will not be part of the graph, but they are still considered for the edges arising from two instances having the same secondary node. Return Nothing if the node list is empty.
haveExclStorage :: List -> Bool #
Is exclusive storage enabled on any node?