Merge pull request #5918 from xiang90/init

etcdmain: only get initial cluster setting if the member is not initi…
This commit is contained in:
Xiang Li 2016-07-13 16:28:32 -07:00 committed by GitHub
commit 071eac3838
2 changed files with 41 additions and 4 deletions

View File

@ -26,6 +26,7 @@ import (
"github.com/coreos/etcd/pkg/cors"
runtimeutil "github.com/coreos/etcd/pkg/runtime"
"github.com/coreos/etcd/pkg/transport"
"github.com/coreos/etcd/pkg/types"
"github.com/coreos/etcd/rafthttp"
"github.com/coreos/pkg/capnslog"
)
@ -81,10 +82,16 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
e.Clients = append(e.Clients, sctx.l)
}
urlsmap, token, uerr := cfg.PeerURLsMapAndToken("etcd")
if uerr != nil {
err = fmt.Errorf("error setting up initial cluster: %v", uerr)
return
var (
urlsmap types.URLsMap
token string
)
if !isMemberInitialized(cfg) {
urlsmap, token, err = cfg.PeerURLsMapAndToken("etcd")
if err != nil {
return nil, fmt.Errorf("error setting up initial cluster: %v", err)
}
}
srvcfg := &etcdserver.ServerConfig{

30
embed/util.go Normal file
View File

@ -0,0 +1,30 @@
// Copyright 2016 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package embed
import (
"path"
"github.com/coreos/etcd/wal"
)
func isMemberInitialized(cfg *Config) bool {
waldir := cfg.WalDir
if waldir == "" {
waldir = path.Join(cfg.Dir, "member", "wal")
}
return wal.Exist(waldir)
}