mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: add shouldDiscover
This commit is contained in:
@@ -48,6 +48,10 @@ func (c *ServerConfig) SnapDir() string { return path.Join(c.DataDir, "snap") }
|
||||
|
||||
func (c *ServerConfig) ID() uint64 { return c.Cluster.FindName(c.Name).ID }
|
||||
|
||||
func (c *ServerConfig) ShouldDiscover() bool {
|
||||
return c.DiscoveryURL != ""
|
||||
}
|
||||
|
||||
// IsBootstrap returns ture if a bootstrap method is provided.
|
||||
func (c *ServerConfig) IsBootstrap() bool {
|
||||
return c.DiscoveryURL != "" || c.ClusterState == ClusterStateValueNew
|
||||
|
||||
@@ -128,7 +128,7 @@ func NewServer(cfg *ServerConfig) *EtcdServer {
|
||||
if !cfg.IsBootstrap() {
|
||||
log.Fatalf("etcd: initial cluster state unset and no wal or discovery URL found")
|
||||
}
|
||||
if cfg.DiscoveryURL != "" {
|
||||
if cfg.ShouldDiscover() {
|
||||
d, err := discovery.New(cfg.DiscoveryURL, cfg.ID(), cfg.Cluster.String())
|
||||
if err != nil {
|
||||
log.Fatalf("etcd: cannot init discovery %v", err)
|
||||
@@ -143,8 +143,8 @@ func NewServer(cfg *ServerConfig) *EtcdServer {
|
||||
}
|
||||
n, w = startNode(cfg)
|
||||
} else {
|
||||
if cfg.DiscoveryURL != "" {
|
||||
log.Printf("etcd: warn: ignoring discovery URL: etcd has already been initialized and has a valid log in %q", cfg.WALDir())
|
||||
if cfg.ShouldDiscover() {
|
||||
log.Printf("etcd: warn: ignoring discovery: etcd has already been initialized and has a valid log in %q", cfg.WALDir())
|
||||
}
|
||||
var index uint64
|
||||
snapshot, err := ss.Load()
|
||||
|
||||
Reference in New Issue
Block a user