Commit 3e83dd48 authored by Iustin Pop's avatar Iustin Pop
Browse files

Prevent demotion from candidate based on pool size

In gnt-cluster modify we prevent demotion from the candidate role if
there are not enough master candidates left.

Reviewed-by: imsnah
parent 4b7735f9
......@@ -2045,6 +2045,19 @@ class LUSetNodeParams(LogicalUnit):
force = self.force = self.op.force
if self.op.master_candidate == False:
cp_size = self.cfg.GetClusterInfo().candidate_pool_size
node_info = self.cfg.GetAllNodesInfo().values()
num_candidates = len([node for node in node_info
if node.master_candidate])
if num_candidates <= cp_size:
msg = ("Not enough master candidates (desired"
" %d, new value will be %d)" % (cp_size, num_candidates-1))
if force:
raise errors.OpPrereqError(msg)
def Exec(self, feedback_fn):
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