Commit 23f06b2b authored by Iustin Pop's avatar Iustin Pop
Browse files

Allow GetMasterCandidateStats to ignore some nodes



This patch modifies ConfigWriter.GetMasterCandidateStats to allow it to
ignore some nodes in the calculation, so that we can use it to predict
cluster state without some nodes (which we know we will modify, and thus
we should not rely on their state).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarOlivier Tharan <olive@google.com>
parent e631cb25
......@@ -945,15 +945,19 @@ class ConfigWriter:
for node in self._UnlockedGetNodeList()])
return my_dict
def _UnlockedGetMasterCandidateStats(self):
def _UnlockedGetMasterCandidateStats(self, exceptions=None):
"""Get the number of current and maximum desired and possible candidates.
@type exceptions: list
@param exceptions: if passed, list of nodes that should be ignored
@rtype: tuple
@return: tuple of (current, desired and possible)
"""
mc_now = mc_max = 0
for node in self._config_data.nodes.itervalues():
for node in self._config_data.nodes.values():
if exceptions and node.name in exceptions:
continue
if not (node.offline or node.drained):
mc_max += 1
if node.master_candidate:
......@@ -962,16 +966,18 @@ class ConfigWriter:
return (mc_now, mc_max)
@locking.ssynchronized(_config_lock, shared=1)
def GetMasterCandidateStats(self):
def GetMasterCandidateStats(self, exceptions=None):
"""Get the number of current and maximum possible candidates.
This is just a wrapper over L{_UnlockedGetMasterCandidateStats}.
@type exceptions: list
@param exceptions: if passed, list of nodes that should be ignored
@rtype: tuple
@return: tuple of (current, max)
"""
return self._UnlockedGetMasterCandidateStats()
return self._UnlockedGetMasterCandidateStats(exceptions)
@locking.ssynchronized(_config_lock)
def MaintainCandidatePool(self):
......
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