[pve-devel] [PATCH cluster 8/8] pvecm add: assert that ringX IPs are available on node add

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Feb 22 16:59:11 CET 2017


If 'ringX_addr' parameters are used on adding a node to a cluster
check if those addresses are actually configured on the to-be-added
node. It makes no sense that the address is not or multiple times
configured.

This prevents a node in limbo, waiting for quorum (if it was the
second node in a cluster, even two node would be in the no-quorum
limbo) where manual pmxcfs kills, local starts and manual
configuration edits which may need to get manually synced to other
cluster members are needed.

The check does not cost much and gets only made on node additions, so
assert with our get_local_ip_from_cidr method that the IP is
configured on any interface.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 data/PVE/CLI/pvecm.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index df94c2e..4366066 100755
--- a/data/PVE/CLI/pvecm.pm
+++ b/data/PVE/CLI/pvecm.pm
@@ -536,6 +536,21 @@ __PACKAGE__->register_method ({
 	    }
 	}
 
+	# check if corosync ring IPs are configured on the current nodes interfaces
+	my $check_ip = sub {
+	    my $ip = shift;
+	    if (defined($ip)) {
+		my $cidr = (Net::IP::ip_is_ipv6($ip)) ? "$ip/128" : "$ip/32";
+		my $configured_ips = PVE::Network::get_local_ip_from_cidr($cidr);
+
+		&$error("cannot use IP '$ip', it must be configured exactly once on local node!\n")
+		    if (scalar(@$configured_ips) != 1);
+	    }
+	};
+
+	&$check_ip($param->{ring0_addr});
+	&$check_ip($param->{ring1_addr});
+
 	warn "warning, ignore the following errors:\n$warnings" if $warnings;
 	die "detected the following error(s):\n$errors" if $errors;
 
-- 
2.1.4





More information about the pve-devel mailing list