Commit d833acc6 authored by Iustin Pop's avatar Iustin Pop
Browse files

Prevent readding of the master node

This breaks Ganeti in multiple ways. If we don't make the check in
gnt-node itself, then bootstrap.SetupNodeDaemon will restart the
master daemon, making the operation fail:

  node1# gnt-node add --readd node1
  Cannot communicate with the master daemon.
  Is it running and listening for connections?

The check in cmdlib is more of a safety check, as we shouldn't reach
it. If we do (via a bad client), then it will prevent breakage in the
job queue/config handling.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarMichael Hanselmann <>
parent cce6f357
......@@ -163,9 +163,9 @@ def AddNode(opts, args):
readd = opts.readd
output = cl.QueryNodes(names=[node], fields=['name', 'sip'],
output = cl.QueryNodes(names=[node], fields=['name', 'sip', 'master'],
node_exists, sip = output[0]
node_exists, sip, is_master = output[0]
except (errors.OpPrereqError, errors.OpExecError):
node_exists = ""
sip = None
......@@ -175,6 +175,9 @@ def AddNode(opts, args):
ToStderr("Node %s not in the cluster"
" - please retry without '--readd'", node)
return 1
if is_master:
ToStderr("Node %s is the master, cannot readd", node)
return 1
if node_exists:
ToStderr("Node %s already in the cluster (as %s)"
......@@ -4053,6 +4053,11 @@ class LUNodeAdd(LogicalUnit):
self.hostname = netutils.GetHostname(name=self.op.node_name,
self.op.node_name =
if self.op.readd and self.op.node_name == self.cfg.GetMasterNode():
raise errors.OpPrereqError("Cannot readd the master node",
if self.op.readd and
raise errors.OpPrereqError("Cannot pass a node group when a node is"
" being readded", errors.ECODE_INVAL)
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