From aa176610f334430733e8d0355aa919c7355634c1 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Fri, 17 Oct 2014 15:37:30 -0700 Subject: [PATCH] main: remove duplicated self name check --- etcdserver/config.go | 4 ++++ main.go | 12 +----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/etcdserver/config.go b/etcdserver/config.go index e2c380832..077b6fe5f 100644 --- a/etcdserver/config.go +++ b/etcdserver/config.go @@ -6,6 +6,7 @@ import ( "path" "github.com/coreos/etcd/pkg/types" + "github.com/coreos/etcd/raft" ) // ServerConfig holds the configuration of etcd as taken from the command line or discovery. @@ -28,6 +29,9 @@ func (c *ServerConfig) Verify() error { if m == nil { return fmt.Errorf("could not find name %v in cluster", c.Name) } + if m.ID == raft.None { + return fmt.Errorf("cannot use None(%x) as member id", raft.None) + } // No identical IPs in the cluster peer list urlMap := make(map[string]bool) diff --git a/main.go b/main.go index e43d14833..31ebfef06 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,6 @@ import ( flagtypes "github.com/coreos/etcd/pkg/flags" "github.com/coreos/etcd/pkg/transport" "github.com/coreos/etcd/proxy" - "github.com/coreos/etcd/raft" ) const ( @@ -124,17 +123,8 @@ func main() { // startEtcd launches the etcd server and HTTP handlers for client/server communication. func startEtcd() { - self := cluster.FindName(*name) - if self == nil { - log.Fatalf("etcd: no member with name=%q exists", *name) - } - - if self.ID == raft.None { - log.Fatalf("etcd: cannot use None(%d) as member id", raft.None) - } - if *dir == "" { - *dir = fmt.Sprintf("%v_etcd_data", self.Name) + *dir = fmt.Sprintf("%v_etcd_data", *name) log.Printf("etcd: no data-dir provided, using default data-dir ./%s", *dir) } if err := os.MkdirAll(*dir, privateDirMode); err != nil {