[pve-devel] [PATCH manager] ui: cluster: require ring0_addr if joinee's ring and node addr differ

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Nov 27 15:22:24 CET 2018


Pass the ring addresses from the node we use to join a cluster with
the encoded cluster info. Use it to determine if the nodes public
address (i.e., the onei t's node name resolves to) differs from it'S
ring0 address, if that's the case and the cluster was created with
PVE tooling then we know that it's highly probable that the ring0 is
on another network than the public net, so require the ring0_addrss
field in this case. If we have a false positive, it's not to bad
here.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/manager6/dc/Cluster.js     |  2 ++
 www/manager6/dc/ClusterEdit.js | 21 ++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/www/manager6/dc/Cluster.js b/www/manager6/dc/Cluster.js
index 6485eab7..38771aac 100644
--- a/www/manager6/dc/Cluster.js
+++ b/www/manager6/dc/Cluster.js
@@ -88,6 +88,7 @@ Ext.define('PVE.ClusterAdministration', {
 		    vm.set('preferred_node', {
 			name: data.preferred_node,
 			addr: nodeinfo.pve_addr,
+			ring_addr: [ nodeinfo.ring0_addr, nodeinfo.ring1_addr ],
 			fp: nodeinfo.pve_fp
 		    });
 		},
@@ -111,6 +112,7 @@ Ext.define('PVE.ClusterAdministration', {
 			joinInfo: {
 			    ipAddress: vm.get('preferred_node.addr'),
 			    fingerprint: vm.get('preferred_node.fp'),
+			    ring_addr: vm.get('preferred_node.ring_addr'),
 			    totem: vm.get('totem')
 			}
 		    });
diff --git a/www/manager6/dc/ClusterEdit.js b/www/manager6/dc/ClusterEdit.js
index 6eaefc98..491c8695 100644
--- a/www/manager6/dc/ClusterEdit.js
+++ b/www/manager6/dc/ClusterEdit.js
@@ -131,9 +131,19 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
 	    info: {
 		fp: '',
 		ip: '',
+		ring0Needed: false,
 		ring1Possible: false,
 		ring1Needed: false
 	    }
+	},
+	formulas: {
+	    ring0EmptyText: function(get) {
+		if (get('info.ring0Needed')) {
+		    return gettext("Cannot use default address safely");
+		} else {
+		    return gettext("Default: IP resolved by node's hostname");
+		}
+	    }
 	}
     },
 
@@ -188,9 +198,15 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
 	    if (!(joinInfo && joinInfo.totem)) {
 		field.valid = false;
 	    } else {
+		var ring0Needed = false;
+		if (joinInfo.ring_addr !== undefined) {
+		    ring0Needed = joinInfo.ring_addr[0] !== joinInfo.ipAddress;
+		}
+
 		info = {
 		    ip: joinInfo.ipAddress,
 		    fp: joinInfo.fingerprint,
+		    ring0Needed: ring0Needed,
 		    ring1Possible: !!joinInfo.totem['interface']['1'],
 		    ring1Needed: !!joinInfo.totem['interface']['1']
 		};
@@ -282,7 +298,10 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
 	    {
 		xtype: 'proxmoxtextfield',
 		fieldLabel: gettext('Corosync Ring 0'),
-		emptyText: gettext("Default: IP resolved by node's hostname"),
+		bind: {
+		    emptyText: '{ring0EmptyText}',
+		    allowBlank: '{!info.ring0Needed}'
+		},
 		skipEmptyText: true,
 		name: 'ring0_addr'
 	    },
-- 
2.19.2





More information about the pve-devel mailing list