etcdmian: fix initialization confilct

Fix #3142

Ignore flags if etcd is already initialized.
This commit is contained in:
Xiang Li 2015-07-19 09:53:57 +08:00 committed by Yicheng Qin
parent 24db661401
commit 6be02ff5ec

View File

@ -93,9 +93,16 @@ func Main() {
which := identifyDataDirOrDie(cfg.dir) which := identifyDataDirOrDie(cfg.dir)
if which != dirEmpty { if which != dirEmpty {
plog.Noticef("the server is already initialized as %v before, starting as etcd %v...", which, which) plog.Noticef("the server is already initialized as %v before, starting as etcd %v...", which, which)
switch which {
case dirMember:
stopped, err = startEtcd(cfg)
case dirProxy:
err = startProxy(cfg)
default:
plog.Panicf("unhandled dir type %v", which)
} }
} else {
shouldProxy := cfg.isProxy() || which == dirProxy shouldProxy := cfg.isProxy()
if !shouldProxy { if !shouldProxy {
stopped, err = startEtcd(cfg) stopped, err = startEtcd(cfg)
if err == discovery.ErrFullCluster && cfg.shouldFallbackToProxy() { if err == discovery.ErrFullCluster && cfg.shouldFallbackToProxy() {
@ -106,6 +113,8 @@ func Main() {
if shouldProxy { if shouldProxy {
err = startProxy(cfg) err = startProxy(cfg)
} }
}
if err != nil { if err != nil {
switch err { switch err {
case discovery.ErrDuplicateID: case discovery.ErrDuplicateID: