From 1977763827b865f098a573b48459ddaaf882890e Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Sat, 21 Mar 2009 15:48:12 +0100 Subject: [PATCH] Handle correctly offline nodes in cluster scoring This patch changes two things with regard to offline nodes: - first, it only calculates the various coefficients across online nodes - second, it adds a new score denoting the percentage of instances which live on such nodes The first change allows correct score computation in presence of offline nodes (whose properties we don't need to take into account), while the second change actively evacuates offline nodes. --- Ganeti/HTools/Cluster.hs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Ganeti/HTools/Cluster.hs b/Ganeti/HTools/Cluster.hs index ba32d4c07..b44cc3b62 100644 --- a/Ganeti/HTools/Cluster.hs +++ b/Ganeti/HTools/Cluster.hs @@ -646,10 +646,11 @@ printNodes ktn nl = in unlines $ (header:map (uncurry helper) snl') -- | Compute the mem and disk covariance. -compDetailedCV :: NodeList -> (Double, Double, Double, Double) +compDetailedCV :: NodeList -> (Double, Double, Double, Double, Double) compDetailedCV nl = let - nodes = Container.elems nl + all_nodes = Container.elems nl + (offline, nodes) = partition Node.offline all_nodes mem_l = map Node.p_mem nodes dsk_l = map Node.p_dsk nodes mem_cv = varianceCoeff mem_l @@ -658,19 +659,25 @@ compDetailedCV nl = n1_score = (fromIntegral n1_l) / (fromIntegral $ length nodes) res_l = map Node.p_rem nodes res_cv = varianceCoeff res_l - in (mem_cv, dsk_cv, n1_score, res_cv) + offline_inst = sum . map (\n -> (length . Node.plist $ n) + + (length . Node.slist $ n)) $ offline + online_inst = sum . map (\n -> (length . Node.plist $ n) + + (length . Node.slist $ n)) $ nodes + off_score = (fromIntegral offline_inst) / + (fromIntegral $ online_inst + offline_inst) + in (mem_cv, dsk_cv, n1_score, res_cv, off_score) -- | Compute the 'total' variance. compCV :: NodeList -> Double compCV nl = - let (mem_cv, dsk_cv, n1_score, res_cv) = compDetailedCV nl - in mem_cv + dsk_cv + n1_score + res_cv + let (mem_cv, dsk_cv, n1_score, res_cv, off_score) = compDetailedCV nl + in mem_cv + dsk_cv + n1_score + res_cv + off_score printStats :: NodeList -> String printStats nl = - let (mem_cv, dsk_cv, n1_score, res_cv) = compDetailedCV nl - in printf "f_mem=%.8f, r_mem=%.8f, f_dsk=%.8f, n1=%.3f" - mem_cv res_cv dsk_cv n1_score + let (mem_cv, dsk_cv, n1_score, res_cv, off_score) = compDetailedCV nl + in printf "f_mem=%.8f, r_mem=%.8f, f_dsk=%.8f, n1=%.3f, uf=%.3f" + mem_cv res_cv dsk_cv n1_score off_score -- Balancing functions -- GitLab