Skip to content

Commit

Permalink
etcdmain: only get initial cluster setting if the member is not initi…
Browse files Browse the repository at this point in the history
…alized
  • Loading branch information
xiang90 committed Jul 11, 2016
1 parent ea0a569 commit 9b8bcc1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
14 changes: 11 additions & 3 deletions etcdmain/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,17 @@ func startEtcdOrProxyV2() {

// startEtcd launches the etcd server and HTTP handlers for client/server communication.
func startEtcd(cfg *config) (<-chan struct{}, error) {
urlsmap, token, err := getPeerURLsMapAndToken(cfg, "etcd")
if err != nil {
return nil, fmt.Errorf("error setting up initial cluster: %v", err)
var (
urlsmap types.URLsMap
token string
err error
)

if !IsMemberInitialized(cfg) {
urlsmap, token, err = getPeerURLsMapAndToken(cfg, "etcd")
if err != nil {
return nil, fmt.Errorf("error setting up initial cluster: %v", err)
}
}

if cfg.PeerAutoTLS && cfg.peerTLSInfo.Empty() {
Expand Down
30 changes: 30 additions & 0 deletions etcdmain/util.go
Original file line number Diff line number Diff line change
@@ -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 etcdmain

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)
}

0 comments on commit 9b8bcc1

Please sign in to comment.