Commit 5bf07049 authored by Iustin Pop's avatar Iustin Pop
Browse files

ConfigWriter: handle the drained node flag

This patch changes the master candidate pool computations in
ConfigWriter to properly handle drained nodes. They are now excluded
from counting towards the reachable number of candidates.

The patch also adds verification of consistency for the node status.

Reviewed-by: imsnah
parent e8d47209
......@@ -304,6 +304,14 @@ class ConfigWriter:
result.append("Not enough master candidates: actual %d, target %d" %
(mc_now, mc_max))
# node checks
for node in data.nodes.values():
if [node.master_candidate, node.drained, node.offline].count(True) > 1:
result.append("Node %s state is invalid: master_candidate=%s,"
" drain=%s, offline=%s" %
(, node.master_candidate, node.drain,
# drbd minors check
d_map, duplicates = self._UnlockedComputeDRBDMap()
for node, minor, instance_a, instance_b in duplicates:
......@@ -903,7 +911,7 @@ class ConfigWriter:
mc_now = mc_max = 0
for node in self._config_data.nodes.itervalues():
if not node.offline:
if not (node.offline or node.drained):
mc_max += 1
if node.master_candidate:
mc_now += 1
......@@ -939,7 +947,7 @@ class ConfigWriter:
if mc_now >= mc_max:
node = self._config_data.nodes[name]
if node.master_candidate or node.offline:
if node.master_candidate or node.offline or node.drained:
node.master_candidate = True
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