mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdmain: improve log when join discovery fails
Before this PR, the log is ``` 2015/09/1 13:18:31 etcdmain: client: etcd cluster is unavailable or misconfigured ``` It is quite hard for people to understand what happens. Now we print out the exact reason for the failure, and explains the way to handle it.
This commit is contained in:
parent
9de7f24301
commit
939aa96a34
@ -160,6 +160,12 @@ func Main() {
|
|||||||
}
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
if etcdserver.IsDiscoveryError(err) {
|
||||||
|
plog.Errorf("%v", err)
|
||||||
|
plog.Infof("discovery token %s was used, but failed to bootstrap the cluster.", cfg.durl)
|
||||||
|
plog.Infof("please generate a new discovery token and try to bootstrap again.")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
plog.Fatalf("%v", err)
|
plog.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ package etcdserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
etcdErr "github.com/coreos/etcd/error"
|
etcdErr "github.com/coreos/etcd/error"
|
||||||
)
|
)
|
||||||
@ -38,3 +39,17 @@ func isKeyNotFound(err error) bool {
|
|||||||
e, ok := err.(*etcdErr.Error)
|
e, ok := err.(*etcdErr.Error)
|
||||||
return ok && e.ErrorCode == etcdErr.EcodeKeyNotFound
|
return ok && e.ErrorCode == etcdErr.EcodeKeyNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type discoveryError struct {
|
||||||
|
op string
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e discoveryError) Error() string {
|
||||||
|
return fmt.Sprintf("failed to %s discovery cluster (%v)", e.op, e.err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsDiscoveryError(err error) bool {
|
||||||
|
_, ok := err.(*discoveryError)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
@ -247,7 +247,7 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
|
|||||||
var err error
|
var err error
|
||||||
str, err = discovery.JoinCluster(cfg.DiscoveryURL, cfg.DiscoveryProxy, m.ID, cfg.InitialPeerURLsMap.String())
|
str, err = discovery.JoinCluster(cfg.DiscoveryURL, cfg.DiscoveryProxy, m.ID, cfg.InitialPeerURLsMap.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, &discoveryError{op: "join", err: err}
|
||||||
}
|
}
|
||||||
urlsmap, err := types.NewURLsMap(str)
|
urlsmap, err := types.NewURLsMap(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user