mirror of https://github.com/hashicorp/consul
Fix test and remove unused method
parent
d77ab91123
commit
6c0bb5a810
|
@ -408,14 +408,23 @@ func (b *Builder) Build() (rt RuntimeConfig, err error) {
|
|||
// derive other bind addresses from the bindAddr
|
||||
rpcBindAddr := b.makeTCPAddr(bindAddr, nil, serverPort)
|
||||
serfBindAddrLAN := b.makeTCPAddr(b.expandFirstIP("serf_lan", c.SerfBindAddrLAN), bindAddr, serfPortLAN)
|
||||
serfBindAddrWAN := b.makeTCPAddr(b.expandFirstIP("serf_wan", c.SerfBindAddrWAN), bindAddr, serfPortWAN)
|
||||
|
||||
// Only initialize serf WAN bind address when its enabled
|
||||
var serfBindAddrWAN *net.TCPAddr
|
||||
if serfPortWAN >= 0 {
|
||||
serfBindAddrWAN = b.makeTCPAddr(b.expandFirstIP("serf_wan", c.SerfBindAddrWAN), bindAddr, serfPortWAN)
|
||||
}
|
||||
|
||||
// derive other advertise addresses from the advertise address
|
||||
advertiseAddrLAN := b.makeIPAddr(b.expandFirstIP("advertise_addr", c.AdvertiseAddrLAN), advertiseAddr)
|
||||
advertiseAddrWAN := b.makeIPAddr(b.expandFirstIP("advertise_addr_wan", c.AdvertiseAddrWAN), advertiseAddrLAN)
|
||||
rpcAdvertiseAddr := &net.TCPAddr{IP: advertiseAddrLAN.IP, Port: serverPort}
|
||||
serfAdvertiseAddrLAN := &net.TCPAddr{IP: advertiseAddrLAN.IP, Port: serfPortLAN}
|
||||
serfAdvertiseAddrWAN := &net.TCPAddr{IP: advertiseAddrWAN.IP, Port: serfPortWAN}
|
||||
// Only initialize serf WAN advertise address when its enabled
|
||||
var serfAdvertiseAddrWAN *net.TCPAddr
|
||||
if serfPortWAN >= 0 {
|
||||
serfAdvertiseAddrWAN = &net.TCPAddr{IP: advertiseAddrWAN.IP, Port: serfPortWAN}
|
||||
}
|
||||
|
||||
// determine client addresses
|
||||
clientAddrs := b.expandIPs("client_addr", c.ClientAddr)
|
||||
|
@ -866,9 +875,12 @@ func (b *Builder) Validate(rt RuntimeConfig) error {
|
|||
if err := addrUnique(inuse, "Serf Advertise LAN", rt.SerfAdvertiseAddrLAN); err != nil {
|
||||
return err
|
||||
}
|
||||
// Validate serf WAN advertise address only when its set
|
||||
if rt.SerfAdvertiseAddrWAN != nil {
|
||||
if err := addrUnique(inuse, "Serf Advertise WAN", rt.SerfAdvertiseAddrWAN); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if b.err != nil {
|
||||
return b.err
|
||||
}
|
||||
|
|
|
@ -1079,7 +1079,17 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
|
|||
}
|
||||
advertise_addr_wan = "1.2.3.4"
|
||||
`},
|
||||
err: nil,
|
||||
patch: func(rt *RuntimeConfig) {
|
||||
rt.AdvertiseAddrWAN = ipAddr("1.2.3.4")
|
||||
rt.SerfAdvertiseAddrWAN = nil
|
||||
rt.SerfBindAddrWAN = nil
|
||||
rt.TaggedAddresses = map[string]string{
|
||||
"lan": "10.0.0.1",
|
||||
"wan": "1.2.3.4",
|
||||
}
|
||||
rt.DataDir = dataDir
|
||||
rt.SerfPortWAN = -1
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "serf bind address lan template",
|
||||
|
|
|
@ -32,7 +32,6 @@ import (
|
|||
"github.com/hashicorp/consul/types"
|
||||
"github.com/hashicorp/raft"
|
||||
raftboltdb "github.com/hashicorp/raft-boltdb"
|
||||
"github.com/hashicorp/serf/coordinate"
|
||||
"github.com/hashicorp/serf/serf"
|
||||
)
|
||||
|
||||
|
@ -1045,15 +1044,6 @@ func (s *Server) GetLANCoordinate() (lib.CoordinateSet, error) {
|
|||
return cs, nil
|
||||
}
|
||||
|
||||
// GetWANCoordinate returns the coordinate of the server in the WAN gossip pool.
|
||||
func (s *Server) GetWANCoordinate() (*coordinate.Coordinate, error) {
|
||||
if s.serfWAN == nil {
|
||||
// Return zero values if WAN federation is disabled
|
||||
return &coordinate.Coordinate{}, nil
|
||||
}
|
||||
return s.serfWAN.GetCoordinate()
|
||||
}
|
||||
|
||||
// Atomically sets a readiness state flag when leadership is obtained, to indicate that server is past its barrier write
|
||||
func (s *Server) setConsistentReadReady() {
|
||||
atomic.StoreInt32(&s.readyForConsistentReads, 1)
|
||||
|
|
Loading…
Reference in New Issue