Commit 53f00b20 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix interaction between down instances and nodes

If an instance is down, it's memory is not reflected in the node used
memory, and thus the node free memory is higher than the actual value.
This patch deducts the memory for such instances from the node free
memory, allowing a correct calculation for such cases.
parent f82f1f39
......@@ -792,15 +792,20 @@ nodeImem node il =
-- | Check cluster data for consistency
checkData :: NodeList -> InstanceList -> NameList -> NameList
-> ([String], NodeList)
checkData nl il ktn kti =
checkData nl il ktn _ =
Container.mapAccum
(\ msgs node ->
let nname = fromJust $ lookup (Node.idx node) ktn
delta_mem = (truncate $ Node.t_mem node) -
(Node.n_mem node) -
(Node.f_mem node) -
(nodeImem node il)
newn = Node.setXmem node delta_mem
nilst = map (flip Container.find $ il) (Node.plist node)
dilst = filter (not . Instance.running) nilst
adj_mem = sum . map Instance.mem $ dilst
delta_mem = (truncate $ Node.t_mem node)
- (Node.n_mem node)
- (Node.f_mem node)
- (nodeImem node il)
+ adj_mem
newn = Node.setFmem (Node.setXmem node delta_mem)
(Node.f_mem node - adj_mem)
umsg = if delta_mem > 16
then (printf "node %s has %6d MB of unaccounted \
\memory "
......
......@@ -16,6 +16,7 @@ module Ganeti.HTools.Node
, setIdx
, setOffline
, setXmem
, setFmem
-- * Instance (re)location
, removePri
, removeSec
......@@ -98,6 +99,10 @@ setOffline t val = t { offline = val }
setXmem :: Node -> Int -> Node
setXmem t val = t { x_mem = val }
-- | Sets the free memory
setFmem :: Node -> Int -> Node
setFmem t val = t { f_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 =
......
......@@ -162,9 +162,9 @@ main = do
idata = fromRight inst_data
(nl, il, csf, ktn, kti) =
Cluster.loadData ndata idata
putStrLn $ printCluster nl il ktn kti
(_, fix_nl) = Cluster.checkData nl il ktn kti
putStrLn $ printCluster fix_nl il ktn kti
when (optShowNodes opts) $ do
let (_, fix_nl) = Cluster.checkData nl il ktn kti
putStr $ Cluster.printNodes ktn fix_nl
let ndata = serializeNodes nl csf ktn
idata = serializeInstances il csf ktn kti
......
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