Commit 0fff97e9 authored by Guido Trotter's avatar Guido Trotter
Browse files

LUAddNode: Auto-make master candidates

When a node is added, if there are not enough master candidates, we'll
automatically promote it.

Reviewed-by: imsnah
parent f08ce603
......@@ -1950,9 +1950,16 @@ class LUAddNode(LogicalUnit):
raise errors.OpPrereqError("Node secondary ip not reachable by TCP"
" based ping to noded port")
cp_size = self.cfg.GetClusterInfo().candidate_pool_size
node_info = self.cfg.GetAllNodesInfo().values()
num_candidates = len([n for n in node_info
if n.master_candidate])
master_candidate = num_candidates < cp_size
self.new_node = objects.Node(name=node,
primary_ip=primary_ip,
secondary_ip=secondary_ip)
secondary_ip=secondary_ip,
master_candidate=master_candidate)
def Exec(self, feedback_fn):
"""Adds the new node to the cluster.
......
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