Browse Source

main: remove duplicated self name check

Yicheng Qin 11 years ago
parent
commit
aa176610f3
2 changed files with 5 additions and 11 deletions
  1. 4 0
      etcdserver/config.go
  2. 1 11
      main.go

+ 4 - 0
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)

+ 1 - 11
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 {