Skip to content

Commit

Permalink
etcdserver: delete member directory when discovery fails
Browse files Browse the repository at this point in the history
When discovery JoinCluster fails returning DiscoveryError, etcd node falls
back to proxy. And in order to start as a proxy, we need to make sure there
are conflicting directories: 'member' and 'proxy' directories cannot be
existent together. This deletes 'member' directory only when startEtcd fails
with DiscoveryError type. This fixes
etcd-io#3827.
  • Loading branch information
gyuho committed Dec 29, 2015
1 parent c3655cb commit 41dd096
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
var err error
str, err = discovery.JoinCluster(cfg.DiscoveryURL, cfg.DiscoveryProxy, m.ID, cfg.InitialPeerURLsMap.String())
if err != nil {
// It removes member directory when NewServer returns error.
// This prevents conflicts with 'proxy' directory when
// the node falls back to proxy.
os.RemoveAll(cfg.MemberDir())
return nil, &DiscoveryError{Op: "join", Err: err}
}
urlsmap, err := types.NewURLsMap(str)
Expand Down

0 comments on commit 41dd096

Please sign in to comment.