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 <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent cce6f357
......@@ -163,9 +163,9 @@ def AddNode(opts, args):
readd = opts.readd
try:
output = cl.QueryNodes(names=[node], fields=['name', 'sip'],
output = cl.QueryNodes(names=[node], fields=['name', 'sip', 'master'],
use_locking=False)
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
else:
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,
family=self.primary_ip_family)
self.op.node_name = self.hostname.name
if self.op.readd and self.op.node_name == self.cfg.GetMasterNode():
raise errors.OpPrereqError("Cannot readd the master node",
errors.ECODE_STATE)
if self.op.readd and self.op.group:
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