consul: Avoid name conflict on WAN ring. Fixes #158.

This commit is contained in:
Armon Dadgar 2014-05-16 14:07:50 -07:00
parent 9832cce4c5
commit 1611d986d6
2 changed files with 9 additions and 5 deletions

View File

@ -179,7 +179,7 @@ func NewServer(config *Config) (*Server, error) {
// Initialize the lan Serf
s.serfLAN, err = s.setupSerf(config.SerfLANConfig,
s.eventChLAN, serfLANSnapshot)
s.eventChLAN, serfLANSnapshot, false)
if err != nil {
s.Shutdown()
return nil, fmt.Errorf("Failed to start lan serf: %v", err)
@ -187,7 +187,7 @@ func NewServer(config *Config) (*Server, error) {
// Initialize the wan Serf
s.serfWAN, err = s.setupSerf(config.SerfWANConfig,
s.eventChWAN, serfWANSnapshot)
s.eventChWAN, serfWANSnapshot, true)
if err != nil {
s.Shutdown()
return nil, fmt.Errorf("Failed to start wan serf: %v", err)
@ -197,10 +197,14 @@ func NewServer(config *Config) (*Server, error) {
}
// setupSerf is used to setup and initialize a Serf
func (s *Server) setupSerf(conf *serf.Config, ch chan serf.Event, path string) (*serf.Serf, error) {
func (s *Server) setupSerf(conf *serf.Config, ch chan serf.Event, path string, wan bool) (*serf.Serf, error) {
addr := s.rpcListener.Addr().(*net.TCPAddr)
conf.Init()
conf.NodeName = s.config.NodeName
if wan {
conf.NodeName = fmt.Sprintf("%s.%s", s.config.NodeName, s.config.Datacenter)
} else {
conf.NodeName = s.config.NodeName
}
conf.Tags["role"] = "consul"
conf.Tags["dc"] = s.config.Datacenter
conf.Tags["vsn"] = fmt.Sprintf("%d", s.config.ProtocolVersion)

View File

@ -98,7 +98,7 @@ func TestServer_StartStop(t *testing.T) {
}
config.RPCAdvertise = &net.TCPAddr{
IP: private.IP,
IP: private,
Port: 8300,
}