From a3892221eea4804f58ce83934c91964e83f4f30c Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 30 Mar 2015 13:30:40 -0700 Subject: [PATCH] *: stop using resolved tcp addr We start to resolve host into tcp addrs since we generate tcp based initial-cluster during srv discovery. However it creates problems around tls and cluster verification. The srv discovery only needs to use resolved the tcp addr to find the local node. It does not have to resolve everything and use the resolved addrs. This fixes #2488 and #2226 --- discovery/srv.go | 4 ++-- etcdmain/config.go | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/discovery/srv.go b/discovery/srv.go index da82bbc37..86365f065 100644 --- a/discovery/srv.go +++ b/discovery/srv.go @@ -68,8 +68,8 @@ func SRVGetCluster(name, dns string, defaultToken string, apurls types.URLs) (st n = fmt.Sprintf("%d", tempName) tempName += 1 } - stringParts = append(stringParts, fmt.Sprintf("%s=%s%s", n, prefix, tcpAddr.String())) - log.Printf("discovery: Got bootstrap from DNS for %s at host %s to %s%s", service, host, prefix, tcpAddr.String()) + stringParts = append(stringParts, fmt.Sprintf("%s=%s%s", n, prefix, host)) + log.Printf("discovery: Got bootstrap from DNS for %s at %s%s", service, prefix, host) } return nil } diff --git a/etcdmain/config.go b/etcdmain/config.go index 71d693810..6c209271b 100644 --- a/etcdmain/config.go +++ b/etcdmain/config.go @@ -15,7 +15,6 @@ package etcdmain import ( - "errors" "flag" "fmt" "log" @@ -26,7 +25,6 @@ import ( "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/pkg/cors" "github.com/coreos/etcd/pkg/flags" - "github.com/coreos/etcd/pkg/netutil" "github.com/coreos/etcd/pkg/transport" "github.com/coreos/etcd/version" ) @@ -260,10 +258,6 @@ func (cfg *config) Parse(arguments []string) error { return err } - if err := cfg.resolveUrls(); err != nil { - return errors.New("cannot resolve DNS hostnames.") - } - if 5*cfg.TickMs > cfg.ElectionMs { return fmt.Errorf("-election-timeout[%vms] should be at least as 5 times as -heartbeat-interval[%vms]", cfg.ElectionMs, cfg.TickMs) } @@ -279,10 +273,6 @@ func initialClusterFromName(name string) string { return fmt.Sprintf("%s=http://localhost:2380,%s=http://localhost:7001", n, n) } -func (cfg *config) resolveUrls() error { - return netutil.ResolveTCPAddrs(cfg.lpurls, cfg.apurls, cfg.lcurls, cfg.acurls) -} - func (cfg config) isNewCluster() bool { return cfg.clusterState.String() == clusterStateFlagNew } func (cfg config) isProxy() bool { return cfg.proxy.String() != proxyFlagOff } func (cfg config) isReadonlyProxy() bool { return cfg.proxy.String() == proxyFlagReadonly }