[pve-devel] [PATCH cluster v2 3/8] cluster create: use new corosync-link format for totem interfaces

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jun 11 19:36:28 CEST 2019


Preparation for enhanced compatibility with new corosync 3/knet
transport. Pretty straight forward switch from ringX_addr to links,
*but*, for configuration backward compatibility corosync still uses
"ringX_addr" as "link address", this will surely add confusion"link
address", this will surely add confusion ...

We drop all the "all IP versions must match" checking code, as
1. it could cope with hostname's anyway
2. links can be on different IP versions with kronosnet

This makes it a bit easier and shorter, we can re-add some (saner)
checking always later on, if people misconfigure this often..

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

changes v1 (RFC) -> v2:
* drop bindnet
* drop IP version checks, replace with a (for now) fixed 'ipv4-6'

 data/PVE/API2/ClusterConfig.pm | 16 ++--------------
 data/PVE/Corosync.pm           | 29 ++++++++---------------------
 2 files changed, 10 insertions(+), 35 deletions(-)

diff --git a/data/PVE/API2/ClusterConfig.pm b/data/PVE/API2/ClusterConfig.pm
index e7142b5..8b1fdbe 100644
--- a/data/PVE/API2/ClusterConfig.pm
+++ b/data/PVE/API2/ClusterConfig.pm
@@ -95,20 +95,8 @@ __PACKAGE__->register_method ({
 		minimum => 1,
 		optional => 1,
 	    },
-	    bindnet0_addr => {
-		type => 'string', format => 'ip',
-		description => "This specifies the network address the corosync ring 0".
-		    " executive should bind to and defaults to the local IP address of the node.",
-		optional => 1,
-	    },
-	    ring0_addr => get_standard_option('corosync-ring0-addr'),
-	    bindnet1_addr => {
-		type => 'string', format => 'ip',
-		description => "This specifies the network address the corosync ring 1".
-		    " executive should bind to and is optional.",
-		optional => 1,
-	    },
-	    ring1_addr => get_standard_option('corosync-ring1-addr'),
+	    link0 => get_standard_option('corosync-link'),
+	    link1 => get_standard_option('corosync-link'),
 	},
     },
     returns => { type => 'string' },
diff --git a/data/PVE/Corosync.pm b/data/PVE/Corosync.pm
index fea7258..0d2a85f 100644
--- a/data/PVE/Corosync.pm
+++ b/data/PVE/Corosync.pm
@@ -202,12 +202,9 @@ sub create_conf {
     my $votes = $param{votes} || 1;
 
     my $local_ip_address = PVE::Cluster::remote_node_ip($nodename);
-    my $ring0_addr = $param{ring0_addr} // $local_ip_address;
-    my $bindnet0_addr = $param{bindnet0_addr} // $ring0_addr;
 
-    my $use_ipv6 = ip_is_ipv6($ring0_addr);
-    die "ring 0 addresses must be from same IP family!\n"
-	if $use_ipv6 != ip_is_ipv6($bindnet0_addr);
+    my $link0 = PVE::Cluster::parse_corosync_link($param{link0});
+    $link0->{address} //= $local_ip_address;
 
     my $conf = {
 	totem => {
@@ -215,10 +212,9 @@ sub create_conf {
 	    secauth => 'on',
 	    cluster_name => $clustername,
 	    config_version => 0,
-	    ip_version => $use_ipv6 ? 'ipv6' : 'ipv4',
+	    ip_version => 'ipv4-6',
 	    interface => {
 		0 => {
-		    bindnetaddr => $bindnet0_addr,
 		    linknumber => 0,
 		},
 	    },
@@ -229,7 +225,7 @@ sub create_conf {
 		    name => $nodename,
 		    nodeid => $nodeid,
 		    quorum_votes => $votes,
-		    ring0_addr => $ring0_addr,
+		    ring0_addr => $link0->{address},
 		},
 	    },
 	},
@@ -242,23 +238,14 @@ sub create_conf {
 	},
     };
 
-    die "Param bindnet1_addr set but ring1_addr not specified!\n"
-	if (defined($param{bindnet1_addr}) && !defined($param{ring1_addr}));
-
-    my $ring1_addr = $param{ring1_addr};
-    my $bindnet1_addr = $param{bindnet1_addr} // $param{ring1_addr};
-
-    if ($bindnet1_addr) {
-	die "ring 1 addresses must be from same IP family as ring 0!\n"
-	    if $use_ipv6 != ip_is_ipv6($bindnet1_addr) ||
-	       $use_ipv6 != ip_is_ipv6($ring1_addr);
+    my $link1 = PVE::Cluster::parse_corosync_link($param{link1});
 
+    if ($link1->{address}) {
 	$conf->{totem}->{interface}->{1} = {
-	    bindnetaddr => $bindnet1_addr,
 	    linknumber => 1,
 	};
-	$conf->{totem}->{rrp_mode} = 'passive';
-	$conf->{nodelist}->{node}->{$nodename}->{ring1_addr} = $ring1_addr;
+	$conf->{totem}->{link_mode} = 'passive';
+	$conf->{nodelist}->{node}->{$nodename}->{ring1_addr} = $link1->{address};
     }
 
     return { main => $conf };
-- 
2.20.1





More information about the pve-devel mailing list