From e97f211ed55bf37d76f29ed608a391b8763f013e Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 7 Oct 2009 17:08:34 +0100
Subject: [PATCH] parseNode: don't lookup values in drained nodes

Currently parseNode skips looking for values in offline nodes, but tries
to read them for drained ones. With this patch we treat offline and
drained nodes in the same way (which is compatible with the iallocator
protocol changes introduced in Ganeti 2.0.4, but also doesn't break
retrocompatibility). As a bonus we don't need to calculate the value of
the internal Node "offline" parameter, because we know that the node is
going to be online anyway, if we lookup values (and it was statically
set to offline, before, in the offline case).

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 Ganeti/HTools/IAlloc.hs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Ganeti/HTools/IAlloc.hs b/Ganeti/HTools/IAlloc.hs
index 801243b9a..5063b9ab8 100644
--- a/Ganeti/HTools/IAlloc.hs
+++ b/Ganeti/HTools/IAlloc.hs
@@ -78,7 +78,7 @@ parseNode n a = do
     let name = n
     offline <- fromObj "offline" a
     drained <- fromObj "drained" a
-    node <- (if offline
+    node <- (if offline || drained
              then return $ Node.create name 0 0 0 0 0 0 True
              else do
                mtotal <- fromObj "total_memory" a
@@ -88,7 +88,7 @@ parseNode n a = do
                dfree  <- fromObj "free_disk"    a
                ctotal <- fromObj "total_cpus"   a
                return $ Node.create n mtotal mnode mfree
-                      dtotal dfree ctotal (offline || drained))
+                      dtotal dfree ctotal False)
     return (name, node)
 
 -- | Top-level parser.
-- 
GitLab