From e623dbe364bec76b8f8e8ce7ff9f8aec3ecce99a Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Thu, 1 Oct 2009 16:36:19 +0100 Subject: [PATCH] Master candidate stats, return one more value Other than returning the current number of candidates, and the number of desired and possible candidates, we also return the maximum possible number, even if greater than our desires. All callers for now ignore this third value. Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/cmdlib.py | 6 +++--- lib/config.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 98147a0e8..3f36b0a04 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -680,7 +680,7 @@ def _AdjustCandidatePool(lu): ", ".join(node.name for node in mod_list)) for name in mod_list: lu.context.ReaddNode(name) - mc_now, mc_max = lu.cfg.GetMasterCandidateStats() + mc_now, mc_max, _ = lu.cfg.GetMasterCandidateStats() if mc_now > mc_max: lu.LogInfo("Note: more nodes are candidates (%d) than desired (%d)" % (mc_now, mc_max)) @@ -2799,7 +2799,7 @@ class LUAddNode(LogicalUnit): exceptions = [node] else: exceptions = [] - mc_now, mc_max = self.cfg.GetMasterCandidateStats(exceptions) + mc_now, mc_max, _ = self.cfg.GetMasterCandidateStats(exceptions) # the new node will increase mc_max with one, so: mc_max = min(mc_max + 1, cp_size) self.master_candidate = mc_now < mc_max @@ -2973,7 +2973,7 @@ class LUSetNodeParams(LogicalUnit): if ((self.op.master_candidate == False or self.op.offline == True or self.op.drained == True) and node.master_candidate): cp_size = self.cfg.GetClusterInfo().candidate_pool_size - num_candidates, _ = self.cfg.GetMasterCandidateStats() + num_candidates, _, _ = self.cfg.GetMasterCandidateStats() if num_candidates <= cp_size: msg = ("Not enough master candidates (desired" " %d, new value will be %d)" % (cp_size, num_candidates-1)) diff --git a/lib/config.py b/lib/config.py index 1761f73cc..41fcf094d 100644 --- a/lib/config.py +++ b/lib/config.py @@ -378,7 +378,7 @@ class ConfigWriter: result.append("Master node is not a master candidate") # master candidate checks - mc_now, mc_max = self._UnlockedGetMasterCandidateStats() + mc_now, mc_max, _ = self._UnlockedGetMasterCandidateStats() if mc_now < mc_max: result.append("Not enough master candidates: actual %d, target %d" % (mc_now, mc_max)) @@ -1015,10 +1015,10 @@ class ConfigWriter: @type exceptions: list @param exceptions: if passed, list of nodes that should be ignored @rtype: tuple - @return: tuple of (current, desired and possible) + @return: tuple of (current, desired and possible, possible) """ - mc_now = mc_max = 0 + mc_now = mc_should = mc_max = 0 for node in self._config_data.nodes.values(): if exceptions and node.name in exceptions: continue @@ -1026,8 +1026,8 @@ class ConfigWriter: mc_max += 1 if node.master_candidate: mc_now += 1 - mc_max = min(mc_max, self._config_data.cluster.candidate_pool_size) - return (mc_now, mc_max) + mc_should = min(mc_max, self._config_data.cluster.candidate_pool_size) + return (mc_now, mc_should, mc_max) @locking.ssynchronized(_config_lock, shared=1) def GetMasterCandidateStats(self, exceptions=None): @@ -1051,7 +1051,7 @@ class ConfigWriter: @return: list with the adjusted nodes (L{objects.Node} instances) """ - mc_now, mc_max = self._UnlockedGetMasterCandidateStats() + mc_now, mc_max, _ = self._UnlockedGetMasterCandidateStats() mod_list = [] if mc_now < mc_max: node_list = self._config_data.nodes.keys() -- GitLab