Commit 2b3b6ddd authored by Guido Trotter's avatar Guido Trotter
Browse files

Verify: add N+1 Memory redundancy verification

For every node we check that we can host all the instances it's currently
secondary for belonging to the same primary. This ensures that if a node fails
all its instances can fit on their secondary node. The code only works when
failover is forced to go to the secondary node, and cannot go to an arbitrary
node in the cluster, which is the case in Ganeti 1.2.

Reviewed-by: iustinp
parent 26b6af5e
......@@ -745,6 +745,34 @@ class LUVerifyCluster(NoHooksLU):
bad = True
return bad
def _VerifyNPlusOneMemory(self, node_info, instance_cfg, feedback_fn):
"""Verify N+1 Memory Resilience.
Check that if one single node dies we can still start all the instances it
was primary for.
"""
bad = False
for node, nodeinfo in node_info.iteritems():
# This code checks that every node which is now listed as secondary has
# enough memory to host all instances it is supposed to should a single
# other node in the cluster fail.
# FIXME: not ready for failover to an arbitrary node
# FIXME: does not support file-backed instances
# WARNING: we currently take into account down instances as well as up
# ones, considering that even if they're down someone might want to start
# them even in the event of a node failure.
for prinode, instances in nodeinfo['sinst-by-pnode'].iteritems():
needed_mem = 0
for instance in instances:
needed_mem += instance_cfg[instance].memory
if nodeinfo['mfree'] < needed_mem:
feedback_fn(" - ERROR: not enough memory on node %s to accomodate"
" failovers should node %s fail" % (node, prinode))
bad = True
return bad
def CheckPrereq(self):
"""Check prerequisites.
......@@ -900,6 +928,15 @@ class LUVerifyCluster(NoHooksLU):
feedback_fn)
bad = bad or result
feedback_fn("* Verifying N+1 Memory redundancy")
result = self._VerifyNPlusOneMemory(node_info, instance_cfg, feedback_fn)
bad = bad or result
feedback_fn("* Other Notes")
if i_non_redundant:
feedback_fn(" - NOTICE: %d non-redundant instance(s) found."
% len(i_non_redundant))
return int(bad)
......
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