From 411f8ad0a08f322069d1c9e9f035fbceb885c73f Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 11 Mar 2008 07:44:49 +0000 Subject: [PATCH] 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 --- lib/cmdlib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 08eddd14d..15c1e1478 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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, source=constants.LOCALHOST_IP_ADDRESS): 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, + timeout=5): + 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") -- GitLab