Skip to content
Snippets Groups Projects
Commit 4c18f468 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

htools: Use the spindle usage in the algorithms


In the same transition also do a simple refactor of the caculation

Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent b003b8c0
No related branches found
No related tags found
No related merge requests found
...@@ -315,6 +315,11 @@ buildPeers t il = ...@@ -315,6 +315,11 @@ buildPeers t il =
new_prem = fromIntegral new_rmem / tMem t new_prem = fromIntegral new_rmem / tMem t
in t {peers=pmap, failN1 = new_failN1, rMem = new_rmem, pRem = new_prem} in t {peers=pmap, failN1 = new_failN1, rMem = new_rmem, pRem = new_prem}
-- | Calculate the new spindle usage
calcSpindleUsage :: Node -> Instance.Instance -> Double
calcSpindleUsage n i = incIf (Instance.usesLocalStorage i) (instSpindles n)
(fromIntegral $ Instance.spindleUsage i)
-- | Assigns an instance to a node as primary and update the used VCPU -- | Assigns an instance to a node as primary and update the used VCPU
-- count, utilisation data and tags map. -- count, utilisation data and tags map.
setPri :: Node -> Instance.Instance -> Node setPri :: Node -> Instance.Instance -> Node
...@@ -323,23 +328,19 @@ setPri t inst = t { pList = Instance.idx inst:pList t ...@@ -323,23 +328,19 @@ setPri t inst = t { pList = Instance.idx inst:pList t
, pCpu = fromIntegral new_count / tCpu t , pCpu = fromIntegral new_count / tCpu t
, utilLoad = utilLoad t `T.addUtil` Instance.util inst , utilLoad = utilLoad t `T.addUtil` Instance.util inst
, pTags = addTags (pTags t) (Instance.tags inst) , pTags = addTags (pTags t) (Instance.tags inst)
, instSpindles = new_spindles , instSpindles = calcSpindleUsage t inst
} }
where new_count = Instance.applyIfOnline inst (+ Instance.vcpus inst) where new_count = Instance.applyIfOnline inst (+ Instance.vcpus inst)
(uCpu t ) (uCpu t )
new_spindles = instSpindles t + if Instance.usesLocalStorage inst
then 1 else 0
-- | Assigns an instance to a node as secondary without other updates. -- | Assigns an instance to a node as secondary without other updates.
setSec :: Node -> Instance.Instance -> Node setSec :: Node -> Instance.Instance -> Node
setSec t inst = t { sList = Instance.idx inst:sList t setSec t inst = t { sList = Instance.idx inst:sList t
, utilLoad = old_load { T.dskWeight = T.dskWeight old_load + , utilLoad = old_load { T.dskWeight = T.dskWeight old_load +
T.dskWeight (Instance.util inst) } T.dskWeight (Instance.util inst) }
, instSpindles = new_spindles , instSpindles = calcSpindleUsage t inst
} }
where old_load = utilLoad t where old_load = utilLoad t
new_spindles = instSpindles t + if Instance.usesLocalStorage inst
then 1 else 0
-- | Computes the new 'pDsk' value, handling nodes without local disk -- | Computes the new 'pDsk' value, handling nodes without local disk
-- storage (we consider all their disk used). -- storage (we consider all their disk used).
......
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