Add a new node filed x_mem
authorIustin Pop <iustin@google.com>
Sun, 22 Mar 2009 09:55:12 +0000 (10:55 +0100)
committerIustin Pop <iustin@google.com>
Sun, 22 Mar 2009 09:55:12 +0000 (10:55 +0100)
Nodes can have some memory unaccounted for, due to (e.g.) hypervisor
overhead, rounding errors in reporting, etc.

It is better if we model this memory explicitly instead of hiding it,
and actually since the n_mem addition it is actually required to do so.

The new attribute is not yet used.

Ganeti/HTools/Node.hs

index 7694c6d..3ecf685 100644 (file)
@@ -15,6 +15,7 @@ module Ganeti.HTools.Node
     , buildPeers
     , setIdx
     , setOffline
+    , setXmem
     -- * Instance (re)location
     , removePri
     , removeSec
@@ -38,6 +39,7 @@ import Ganeti.HTools.Utils
 data Node = Node { t_mem :: Double -- ^ total memory (MiB)
                  , n_mem :: Int    -- ^ node memory (MiB)
                  , f_mem :: Int    -- ^ free memory (MiB)
+                 , x_mem :: Int    -- ^ unaccounted memory (MiB)
                  , t_dsk :: Double -- ^ total disk space (MiB)
                  , f_dsk :: Int    -- ^ free disk space (MiB)
                  , plist :: [Int]  -- ^ list of primary instance indices
@@ -79,7 +81,8 @@ create mem_t_init mem_n_init mem_f_init dsk_t_init dsk_f_init =
       p_mem = (fromIntegral mem_f_init) / mem_t_init,
       p_dsk = (fromIntegral dsk_f_init) / dsk_t_init,
       p_rem = 0,
-      offline = False
+      offline = False,
+      x_mem = 0
     }
 
 -- | Changes the index.
@@ -91,6 +94,10 @@ setIdx t i = t {idx = i}
 setOffline :: Node -> Bool -> Node
 setOffline t val = t { offline = val }
 
+-- | Sets the unnaccounted memory
+setXmem :: Node -> Int -> Node
+setXmem t val = t { x_mem = val }
+
 -- | Given the rmem, free memory and disk, computes the failn1 status.
 computeFailN1 :: Int -> Int -> Int -> Bool
 computeFailN1 new_rmem new_mem new_dsk =