Commit 5f3b040a authored by Iustin Pop's avatar Iustin Pop
Browse files

Temporary fix for hspace's NPU calculation



hspace computes the NPU (normalised CPU units) via the
(used|pool|avail) VCPU divided by the (currently cluster-wide) max
vcpu_ratio.

However, in the future we'll have variable vcpu_ratios, so we can't
the calculation as such. We temporarily change to computing the
average vcpu_ratio across the cluster, however long-term this needs to
be improved, as ∑ (Vi/Pi) ≠ ∑ Vi / ∑ Pi. In the meantime we implement
this patch to remove the use of a global mcpu variable.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 487e1962
......@@ -228,14 +228,16 @@ formatRSpec m_cpu s r =
]
-- | Shows allocations stats.
printAllocationStats :: Double -> Node.List -> Node.List -> IO ()
printAllocationStats m_cpu ini_nl fin_nl = do
printAllocationStats :: Node.List -> Node.List -> IO ()
printAllocationStats ini_nl fin_nl = do
let ini_stats = Cluster.totalResources ini_nl
fin_stats = Cluster.totalResources fin_nl
avg_vcpu_ratio = fromIntegral (Cluster.csVcpu fin_stats) /
Cluster.csTcpu fin_stats
(rini, ralo, runa) = Cluster.computeAllocationDelta ini_stats fin_stats
printKeys $ formatRSpec m_cpu "USED" rini
printKeys $ formatRSpec m_cpu "POOL"ralo
printKeys $ formatRSpec m_cpu "UNAV" runa
printKeys $ formatRSpec avg_vcpu_ratio "USED" rini
printKeys $ formatRSpec avg_vcpu_ratio "POOL"ralo
printKeys $ formatRSpec avg_vcpu_ratio "UNAV" runa
-- | Ensure a value is quoted if needed.
ensureQuoted :: String -> String
......@@ -309,14 +311,14 @@ printISpec False ispec spec disk_template =
(formatResources ispec specData) (diskTemplateToRaw disk_template)
-- | Prints the tiered results.
printTiered :: Bool -> [(RSpec, Int)] -> Double
printTiered :: Bool -> [(RSpec, Int)]
-> Node.List -> Node.List -> [(FailMode, Int)] -> IO ()
printTiered True spec_map m_cpu nl trl_nl _ = do
printTiered True spec_map nl trl_nl _ = do
printKeys $ printStats PTiered (Cluster.totalResources trl_nl)
printKeys [("TSPEC", unwords (formatSpecMap spec_map))]
printAllocationStats m_cpu nl trl_nl
printAllocationStats nl trl_nl
printTiered False spec_map _ ini_nl fin_nl sreason = do
printTiered False spec_map ini_nl fin_nl sreason = do
_ <- printf "Tiered allocation results:\n"
if null spec_map
then putStrLn " - no instances allocated"
......@@ -449,7 +451,7 @@ main opts args = do
(instFromSpec tspec disk_template) allocnodes [] [])
tspec disk_template SpecTiered opts
printTiered machine_r spec_map (optMcpu opts) nl trl_nl treason
printTiered machine_r spec_map nl trl_nl treason
-- Run the standard (avg-mode) allocation
......
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