]> git.proxmox.com Git - pve-cluster.git/commitdiff
pvecm add: assert that ringX IPs are available on node add
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 22 Feb 2017 15:59:11 +0000 (16:59 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Feb 2017 10:56:47 +0000 (11:56 +0100)
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@proxmox.com>
data/PVE/CLI/pvecm.pm

index df94c2e883d398759cd05bc0ac1ed28e8c9c69f5..436606613642cbeeceb7f1309981b8787363d5f4 100755 (executable)
@@ -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;