From 86ecce4a4fec4c95352cd78786ae58f94e9cd2b2 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 15 Apr 2010 11:27:44 +0200 Subject: [PATCH] Introduce total vcpu tracking in CStats We add a new field that tracks the available virtual cpus (expressed as node cpus times the vcpu ratio). --- Ganeti/HTools/Cluster.hs | 10 +++++++++- Ganeti/HTools/Node.hs | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Ganeti/HTools/Cluster.hs b/Ganeti/HTools/Cluster.hs index 0bcd07415..c9454893c 100644 --- a/Ganeti/HTools/Cluster.hs +++ b/Ganeti/HTools/Cluster.hs @@ -94,6 +94,9 @@ data CStats = CStats { csFmem :: Int -- ^ Cluster free mem , csTmem :: Double -- ^ Cluster total mem , csTdsk :: Double -- ^ Cluster total disk , csTcpu :: Double -- ^ Cluster total cpus + , csVcpu :: Int -- ^ Cluster virtual cpus (if + -- node pCpu has been set, + -- otherwise -1) , csXmem :: Int -- ^ Unnacounted for mem , csNmem :: Int -- ^ Node own memory , csScore :: Score -- ^ The cluster score @@ -125,7 +128,7 @@ computeBadItems nl il = -- | Zero-initializer for the CStats type emptyCStats :: CStats -emptyCStats = CStats 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +emptyCStats = CStats 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -- | Update stats with data from a new node updateCStats :: CStats -> Node.Node -> CStats @@ -135,6 +138,7 @@ updateCStats cs node = csMmem = x_mmem, csMdsk = x_mdsk, csMcpu = x_mcpu, csImem = x_imem, csIdsk = x_idsk, csIcpu = x_icpu, csTmem = x_tmem, csTdsk = x_tdsk, csTcpu = x_tcpu, + csVcpu = x_vcpu, csXmem = x_xmem, csNmem = x_nmem, csNinst = x_ninst } = cs @@ -145,6 +149,7 @@ updateCStats cs node = - Node.xMem node - Node.fMem node inc_icpu = Node.uCpu node inc_idsk = truncate (Node.tDsk node) - Node.fDsk node + inc_vcpu = Node.hiCpu node in cs { csFmem = x_fmem + Node.fMem node , csFdsk = x_fdsk + Node.fDsk node @@ -160,6 +165,9 @@ updateCStats cs node = , csTmem = x_tmem + Node.tMem node , csTdsk = x_tdsk + Node.tDsk node , csTcpu = x_tcpu + Node.tCpu node + , csVcpu = if inc_vcpu == Node.noLimitInt + then Node.noLimitInt + else x_vcpu + inc_vcpu , csXmem = x_xmem + Node.xMem node , csNmem = x_nmem + Node.nMem node , csNinst = x_ninst + length (Node.pList node) diff --git a/Ganeti/HTools/Node.hs b/Ganeti/HTools/Node.hs index 5c6f51871..92a1a02e4 100644 --- a/Ganeti/HTools/Node.hs +++ b/Ganeti/HTools/Node.hs @@ -58,6 +58,7 @@ module Ganeti.HTools.Node , AssocList , AllocElement , noSecondary + , noLimitInt ) where import Data.List -- GitLab