From e87a419f4b99ba24da2f1dc7f55509b4dc0e0e35 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 15 Apr 2010 16:16:53 +0200
Subject: [PATCH] Fix Node hiCpu computation

In case we're not enabling limits, let's restrict this to -1, instead of
-1 times the number of pcpus.
---
 Ganeti/HTools/Node.hs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Ganeti/HTools/Node.hs b/Ganeti/HTools/Node.hs
index 92a1a02e4..0abec278a 100644
--- a/Ganeti/HTools/Node.hs
+++ b/Ganeti/HTools/Node.hs
@@ -242,7 +242,11 @@ setMdsk t val = t { mDsk = val,
 
 -- | Sets the max cpu usage ratio
 setMcpu :: Node -> Double -> Node
-setMcpu t val = t { mCpu = val, hiCpu = floor (val * tCpu t) }
+setMcpu t val = t { mCpu = val, hiCpu = hcpu }
+    where new_hcpu = floor (val * tCpu t)::Int
+          hcpu = if new_hcpu < 0
+                 then noLimitInt
+                 else new_hcpu
 
 -- | Computes the maximum reserved memory for peers from a peer map.
 computeMaxRes :: P.PeerMap -> P.Elem
-- 
GitLab