Commit 411f8ad0 authored by Iustin Pop's avatar Iustin Pop
Browse files

Disable cluster init with a reachable IP

Make the cluster init fail if the IP to which the cluster name resolved
is already reachable by the master node. This is not a foolproof
solution, but it allows a cheap method of detecting simple mistakes.

It will also disallow using the master node name as cluster name (which
is something good).

The only drawbacks that I see are:
  - you are not allowed to do this, which might come in handy in cluster
    upgrades; but since we support rename, this is mitigated
  - cluster init takes longer now (+the timeout value, set to 5
    seconds), but since this is a one-off operation, it should be ok

Reviewed-by: ultrotter
parent b15d625f
......@@ -514,8 +514,6 @@ class LUInitCluster(LogicalUnit):
" range (%s). Please fix DNS or %s." %
(hostname.ip, constants.ETC_HOSTS))
self.clustername = clustername = utils.HostInfo(self.op.cluster_name)
if not utils.TcpPing(hostname.ip, constants.DEFAULT_NODED_PORT,
raise errors.OpPrereqError("Inconsistency: this host's name resolves"
......@@ -523,6 +521,12 @@ class LUInitCluster(LogicalUnit):
" belong to this host."
" Aborting." % hostname.ip)
self.clustername = clustername = utils.HostInfo(self.op.cluster_name)
if utils.TcpPing(clustername.ip, constants.DEFAULT_NODED_PORT,
raise errors.OpPrereqError("Cluster IP already active. Aborting.")
secondary_ip = getattr(self.op, "secondary_ip", None)
if secondary_ip and not utils.IsValidIP(secondary_ip):
raise errors.OpPrereqError("Invalid secondary ip given")
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