From 5bf07049c1ab8158b51e1e5336c33bb58b182755 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 10 Feb 2009 14:46:26 +0000 Subject: [PATCH] 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 --- lib/config.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/config.py b/lib/config.py index d7a1e9f77..a6f3d6905 100644 --- a/lib/config.py +++ b/lib/config.py @@ -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.name, node.master_candidate, node.drain, + node.offline)) + # 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: break node = self._config_data.nodes[name] - if node.master_candidate or node.offline: + if node.master_candidate or node.offline or node.drained: continue mod_list.append(node) node.master_candidate = True -- GitLab