Don't require serf advertise address for clients
This commit is contained in:
parent
1c4195b985
commit
407657519f
|
@ -318,12 +318,13 @@ func TestAgent_ServerConfig(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_ClientConfig(t *testing.T) {
|
func TestAgent_ClientConfig(t *testing.T) {
|
||||||
conf := DefaultConfig()
|
conf := DefaultConfig()
|
||||||
// enabled just to allow using localhost for all addresses
|
|
||||||
conf.DevMode = true
|
|
||||||
a := &Agent{config: conf}
|
|
||||||
conf.Client.Enabled = true
|
conf.Client.Enabled = true
|
||||||
conf.Addresses.HTTP = "127.0.0.1"
|
|
||||||
|
// For Clients HTTP and RPC must be set (Serf can be skipped)
|
||||||
|
conf.Addresses.HTTP = "169.254.0.1"
|
||||||
|
conf.Addresses.RPC = "169.254.0.1"
|
||||||
conf.Ports.HTTP = 5678
|
conf.Ports.HTTP = 5678
|
||||||
|
a := &Agent{config: conf}
|
||||||
|
|
||||||
if err := conf.normalizeAddrs(); err != nil {
|
if err := conf.normalizeAddrs(); err != nil {
|
||||||
t.Fatalf("error normalizing config: %v", err)
|
t.Fatalf("error normalizing config: %v", err)
|
||||||
|
@ -333,7 +334,7 @@ func TestAgent_ClientConfig(t *testing.T) {
|
||||||
t.Fatalf("got err: %v", err)
|
t.Fatalf("got err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedHttpAddr := "127.0.0.1:5678"
|
expectedHttpAddr := "169.254.0.1:5678"
|
||||||
if c.Node.HTTPAddr != expectedHttpAddr {
|
if c.Node.HTTPAddr != expectedHttpAddr {
|
||||||
t.Fatalf("Expected http addr: %v, got: %v", expectedHttpAddr, c.Node.HTTPAddr)
|
t.Fatalf("Expected http addr: %v, got: %v", expectedHttpAddr, c.Node.HTTPAddr)
|
||||||
}
|
}
|
||||||
|
@ -342,7 +343,7 @@ func TestAgent_ClientConfig(t *testing.T) {
|
||||||
conf.DevMode = true
|
conf.DevMode = true
|
||||||
a = &Agent{config: conf}
|
a = &Agent{config: conf}
|
||||||
conf.Client.Enabled = true
|
conf.Client.Enabled = true
|
||||||
conf.Addresses.HTTP = "127.0.0.1"
|
conf.Addresses.HTTP = "169.254.0.1"
|
||||||
|
|
||||||
if err := conf.normalizeAddrs(); err != nil {
|
if err := conf.normalizeAddrs(); err != nil {
|
||||||
t.Fatalf("error normalizing config: %v", err)
|
t.Fatalf("error normalizing config: %v", err)
|
||||||
|
@ -352,7 +353,7 @@ func TestAgent_ClientConfig(t *testing.T) {
|
||||||
t.Fatalf("got err: %v", err)
|
t.Fatalf("got err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedHttpAddr = "127.0.0.1:4646"
|
expectedHttpAddr = "169.254.0.1:4646"
|
||||||
if c.Node.HTTPAddr != expectedHttpAddr {
|
if c.Node.HTTPAddr != expectedHttpAddr {
|
||||||
t.Fatalf("Expected http addr: %v, got: %v", expectedHttpAddr, c.Node.HTTPAddr)
|
t.Fatalf("Expected http addr: %v, got: %v", expectedHttpAddr, c.Node.HTTPAddr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -694,11 +694,14 @@ func (c *Config) normalizeAddrs() error {
|
||||||
}
|
}
|
||||||
c.AdvertiseAddrs.RPC = addr
|
c.AdvertiseAddrs.RPC = addr
|
||||||
|
|
||||||
addr, err = normalizeAdvertise(c.AdvertiseAddrs.Serf, c.Addresses.Serf, c.Ports.Serf, c.DevMode)
|
// Skip serf if server is disabled
|
||||||
if err != nil {
|
if c.Server != nil && c.Server.Enabled {
|
||||||
return fmt.Errorf("Failed to parse Serf advertise address: %v", err)
|
addr, err = normalizeAdvertise(c.AdvertiseAddrs.Serf, c.Addresses.Serf, c.Ports.Serf, c.DevMode)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Failed to parse Serf advertise address: %v", err)
|
||||||
|
}
|
||||||
|
c.AdvertiseAddrs.Serf = addr
|
||||||
}
|
}
|
||||||
c.AdvertiseAddrs.Serf = addr
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue