From e53dba3848ee393a945859f22e21534e8b9b2aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Wed, 26 Jun 2019 09:40:19 +0200 Subject: [PATCH] MM-16400: Adding more control over bind and advertising address in cluster configuration (#11283) --- model/cluster_discovery.go | 8 ++++++-- model/cluster_discovery_test.go | 4 ++-- model/config.go | 10 ++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/model/cluster_discovery.go b/model/cluster_discovery.go index 42361f80b1..9fbd84fe41 100644 --- a/model/cluster_discovery.go +++ b/model/cluster_discovery.go @@ -46,10 +46,14 @@ func (o *ClusterDiscovery) AutoFillHostname() { } } -func (o *ClusterDiscovery) AutoFillIpAddress(iface string) { +func (o *ClusterDiscovery) AutoFillIpAddress(iface string, ipAddress string) { // attempt to set the hostname to the first non-local IP address if len(o.Hostname) == 0 { - o.Hostname = GetServerIpAddress(iface) + if len(ipAddress) > 0 { + o.Hostname = ipAddress + } else { + o.Hostname = GetServerIpAddress(iface) + } } } diff --git a/model/cluster_discovery_test.go b/model/cluster_discovery_test.go index 012f710639..0e4aaba4b0 100644 --- a/model/cluster_discovery_test.go +++ b/model/cluster_discovery_test.go @@ -53,7 +53,7 @@ func TestClusterDiscovery(t *testing.T) { o.Hostname = "" o.AutoFillHostname() - o.AutoFillIpAddress("") + o.AutoFillIpAddress("", "") o.Hostname = "" - o.AutoFillIpAddress("") + o.AutoFillIpAddress("", "") } diff --git a/model/config.go b/model/config.go index b210a301f2..784a309986 100644 --- a/model/config.go +++ b/model/config.go @@ -673,6 +673,8 @@ type ClusterSettings struct { ClusterName *string `restricted:"true"` OverrideHostname *string `restricted:"true"` NetworkInterface *string `restricted:"true"` + BindAddress *string `restricted:"true"` + AdvertiseAddress *string `restricted:"true"` UseIpAddress *bool `restricted:"true"` UseExperimentalGossip *bool `restricted:"true"` ReadOnlyConfig *bool `restricted:"true"` @@ -700,6 +702,14 @@ func (s *ClusterSettings) SetDefaults() { s.NetworkInterface = NewString("") } + if s.BindAddress == nil { + s.BindAddress = NewString("") + } + + if s.AdvertiseAddress == nil { + s.AdvertiseAddress = NewString("") + } + if s.UseIpAddress == nil { s.UseIpAddress = NewBool(true) }