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

A few fixes related to master candidates

This patch:
  - fixes cluster verify when all nodes are master candidates, but the
    candidate_pool_size is higher
  - warn when the master node is not marked as candidate
  - disable setting master node to regular node
  - don't pass the master node to context.ReaddNode since the job queue
    doesn't like getting our own node name

Reviewed-by: ultrotter
parent ec85e3d5
......@@ -2100,6 +2100,9 @@ class LUSetNodeParams(LogicalUnit):
force = self.force = self.op.force
if self.op.master_candidate == False:
if self.op.node_name == self.cfg.GetMasterNode():
raise errors.OpPrereqError("The master node has to be a"
" master candidate")
cp_size = self.cfg.GetClusterInfo().candidate_pool_size
node_info = self.cfg.GetAllNodesInfo().values()
num_candidates = len([node for node in node_info
......@@ -2129,7 +2132,8 @@ class LUSetNodeParams(LogicalUnit):
# this will trigger configuration file update, if needed
self.cfg.Update(node)
# this will trigger job queue propagation or cleanup
self.context.ReaddNode(node)
if self.op.node_name != self.cfg.GetMasterNode():
self.context.ReaddNode(node)
return result
......
......@@ -272,14 +272,17 @@ class ConfigWriter:
result.append("Highest used port mismatch, saved %s, computed %s" %
(data.cluster.highest_used_port, keys[-1]))
if not data.nodes[data.cluster.master_node].master_candidate:
result.append("Master node is not a master candidate")
cp_size = data.cluster.candidate_pool_size
num_c = 0
for node in data.nodes.values():
if node.master_candidate:
num_c += 1
if cp_size > num_c:
result.append("Not enough master candidates: actual %d, desired %d" %
(num_c, cp_size))
if cp_size > num_c and num_c < len(data.nodes):
result.append("Not enough master candidates: actual %d, desired %d,"
" %d total nodes" % (num_c, cp_size, len(data.nodes)))
return result
......
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