From af3de22d4f6ca5645992753b2a3e8637038af388 Mon Sep 17 00:00:00 2001 From: Evan Gilman Date: Sat, 10 Sep 2016 10:53:53 -0700 Subject: [PATCH] Remove old address advertise config code --- command/agent/agent.go | 20 +++----------------- command/agent/agent_test.go | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index 05f777933..f09cacb32 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -134,23 +134,6 @@ func (a *Agent) serverConfig() (*nomad.Config, error) { conf.EnabledSchedulers = a.config.Server.EnabledSchedulers } - // Set up the advertise addrs - if addr := a.config.AdvertiseAddrs.Serf; addr != "" { - serfAddr, err := net.ResolveTCPAddr("tcp", addr) - if err != nil { - return nil, fmt.Errorf("error resolving serf advertise address: %s", err) - } - conf.SerfConfig.MemberlistConfig.AdvertiseAddr = serfAddr.IP.String() - conf.SerfConfig.MemberlistConfig.AdvertisePort = serfAddr.Port - } - if addr := a.config.AdvertiseAddrs.RPC; addr != "" { - rpcAddr, err := net.ResolveTCPAddr("tcp", addr) - if err != nil { - return nil, fmt.Errorf("error resolving rpc advertise address: %s", err) - } - conf.RPCAdvertise = rpcAddr - } - // Set up the bind addresses rpcAddr, err := a.getRPCAddr(true) if err != nil { @@ -181,6 +164,9 @@ func (a *Agent) serverConfig() (*nomad.Config, error) { a.serverHTTPAddr = net.JoinHostPort(httpAddr.IP.String(), strconv.Itoa(httpAddr.Port)) a.serverRPCAddr = net.JoinHostPort(rpcAddr.IP.String(), strconv.Itoa(rpcAddr.Port)) a.serverSerfAddr = net.JoinHostPort(serfAddr.IP.String(), strconv.Itoa(serfAddr.Port)) + conf.RPCAdvertise = rpcAddr + conf.SerfConfig.MemberlistConfig.AdvertiseAddr = serfAddr.IP.String() + conf.SerfConfig.MemberlistConfig.AdvertisePort = serfAddr.Port // Set up gc threshold and heartbeat grace period if gcThreshold := a.config.Server.NodeGCThreshold; gcThreshold != "" { diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 14d13c1c8..5f24403cd 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -181,7 +181,7 @@ func TestAgent_ServerConfig(t *testing.T) { } // It correctly identifies the bind address when requested - if addr := a.selectAddr(a.getHTTPAddr, true); addr != "127.0.0.2:4646" { + if addr, err := a.selectAddr(a.getHTTPAddr, true); addr != "127.0.0.2:4646" || err != nil { t.Fatalf("expect 127.0.0.2:4646, got: %s", addr) }