mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3794 from yichengq/fix-proxy-term
etcdmain: fix parsing discovery error
This commit is contained in:
commit
fe165de1d1
@ -124,9 +124,11 @@ func Main() {
|
|||||||
shouldProxy := cfg.isProxy()
|
shouldProxy := cfg.isProxy()
|
||||||
if !shouldProxy {
|
if !shouldProxy {
|
||||||
stopped, err = startEtcd(cfg)
|
stopped, err = startEtcd(cfg)
|
||||||
if err == discovery.ErrFullCluster && cfg.shouldFallbackToProxy() {
|
if derr, ok := err.(*etcdserver.DiscoveryError); ok && derr.Err == discovery.ErrFullCluster {
|
||||||
plog.Noticef("discovery cluster full, falling back to %s", fallbackFlagProxy)
|
if cfg.shouldFallbackToProxy() {
|
||||||
shouldProxy = true
|
plog.Noticef("discovery cluster full, falling back to %s", fallbackFlagProxy)
|
||||||
|
shouldProxy = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if shouldProxy {
|
if shouldProxy {
|
||||||
@ -135,39 +137,39 @@ func Main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err {
|
if derr, ok := err.(*etcdserver.DiscoveryError); ok {
|
||||||
case discovery.ErrDuplicateID:
|
switch derr.Err {
|
||||||
plog.Errorf("member %q has previously registered with discovery service token (%s).", cfg.name, cfg.durl)
|
case discovery.ErrDuplicateID:
|
||||||
plog.Errorf("But etcd could not find valid cluster configuration in the given data dir (%s).", cfg.dir)
|
plog.Errorf("member %q has previously registered with discovery service token (%s).", cfg.name, cfg.durl)
|
||||||
plog.Infof("Please check the given data dir path if the previous bootstrap succeeded")
|
plog.Errorf("But etcd could not find valid cluster configuration in the given data dir (%s).", cfg.dir)
|
||||||
plog.Infof("or use a new discovery token if the previous bootstrap failed.")
|
plog.Infof("Please check the given data dir path if the previous bootstrap succeeded")
|
||||||
case discovery.ErrDuplicateName:
|
plog.Infof("or use a new discovery token if the previous bootstrap failed.")
|
||||||
plog.Errorf("member with duplicated name has registered with discovery service token(%s).", cfg.durl)
|
case discovery.ErrDuplicateName:
|
||||||
plog.Errorf("please check (cURL) the discovery token for more information.")
|
plog.Errorf("member with duplicated name has registered with discovery service token(%s).", cfg.durl)
|
||||||
plog.Errorf("please do not reuse the discovery token and generate a new one to bootstrap the cluster.")
|
plog.Errorf("please check (cURL) the discovery token for more information.")
|
||||||
default:
|
plog.Errorf("please do not reuse the discovery token and generate a new one to bootstrap the cluster.")
|
||||||
if strings.Contains(err.Error(), "include") && strings.Contains(err.Error(), "--initial-cluster") {
|
default:
|
||||||
plog.Infof("%v", err)
|
|
||||||
if cfg.initialCluster == initialClusterFromName(cfg.name) {
|
|
||||||
plog.Infof("forgot to set --initial-cluster flag?")
|
|
||||||
}
|
|
||||||
if types.URLs(cfg.apurls).String() == defaultInitialAdvertisePeerURLs {
|
|
||||||
plog.Infof("forgot to set --initial-advertise-peer-urls flag?")
|
|
||||||
}
|
|
||||||
if cfg.initialCluster == initialClusterFromName(cfg.name) && len(cfg.durl) == 0 {
|
|
||||||
plog.Infof("if you want to use discovery service, please set --discovery flag.")
|
|
||||||
}
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
if etcdserver.IsDiscoveryError(err) {
|
|
||||||
plog.Errorf("%v", err)
|
plog.Errorf("%v", err)
|
||||||
plog.Infof("discovery token %s was used, but failed to bootstrap the cluster.", cfg.durl)
|
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.")
|
plog.Infof("please generate a new discovery token and try to bootstrap again.")
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
plog.Fatalf("%v", err)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
os.Exit(1)
|
|
||||||
|
if strings.Contains(err.Error(), "include") && strings.Contains(err.Error(), "--initial-cluster") {
|
||||||
|
plog.Infof("%v", err)
|
||||||
|
if cfg.initialCluster == initialClusterFromName(cfg.name) {
|
||||||
|
plog.Infof("forgot to set --initial-cluster flag?")
|
||||||
|
}
|
||||||
|
if types.URLs(cfg.apurls).String() == defaultInitialAdvertisePeerURLs {
|
||||||
|
plog.Infof("forgot to set --initial-advertise-peer-urls flag?")
|
||||||
|
}
|
||||||
|
if cfg.initialCluster == initialClusterFromName(cfg.name) && len(cfg.durl) == 0 {
|
||||||
|
plog.Infof("if you want to use discovery service, please set --discovery flag.")
|
||||||
|
}
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
plog.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
osutil.HandleInterrupts()
|
osutil.HandleInterrupts()
|
||||||
|
@ -40,16 +40,11 @@ func isKeyNotFound(err error) bool {
|
|||||||
return ok && e.ErrorCode == etcdErr.EcodeKeyNotFound
|
return ok && e.ErrorCode == etcdErr.EcodeKeyNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
type discoveryError struct {
|
type DiscoveryError struct {
|
||||||
op string
|
Op string
|
||||||
err error
|
Err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e discoveryError) Error() string {
|
func (e DiscoveryError) Error() string {
|
||||||
return fmt.Sprintf("failed to %s discovery cluster (%v)", e.op, e.err)
|
return fmt.Sprintf("failed to %s discovery cluster (%v)", e.Op, e.Err)
|
||||||
}
|
|
||||||
|
|
||||||
func IsDiscoveryError(err error) bool {
|
|
||||||
_, ok := err.(*discoveryError)
|
|
||||||
return ok
|
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,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, &discoveryError{op: "join", err: 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