mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #2809 from xiang90/fix_discovery_err
discovery: do not return raw error from etcd store
This commit is contained in:
commit
93b610ac8d
@ -183,7 +183,7 @@ func (d *discovery) createSelf(contents string) error {
|
||||
resp, err := d.c.Create(ctx, d.selfKey(), contents)
|
||||
cancel()
|
||||
if err != nil {
|
||||
if eerr, ok := err.(*client.Error); ok && eerr.Code == client.ErrorCodeNodeExist {
|
||||
if eerr, ok := err.(client.Error); ok && eerr.Code == client.ErrorCodeNodeExist {
|
||||
return ErrDuplicateID
|
||||
}
|
||||
return err
|
||||
|
@ -318,6 +318,7 @@ func TestCreateSelf(t *testing.T) {
|
||||
|
||||
c := &clientWithResp{rs: rs, w: w}
|
||||
errc := &clientWithErr{err: errors.New("create err"), w: w}
|
||||
errdupc := &clientWithErr{err: client.Error{Code: client.ErrorCodeNodeExist}}
|
||||
errwc := &clientWithResp{rs: rs, w: errw}
|
||||
|
||||
tests := []struct {
|
||||
@ -330,6 +331,8 @@ func TestCreateSelf(t *testing.T) {
|
||||
{errc, errc.err},
|
||||
// watcher.next retuens an error
|
||||
{errwc, errw.err},
|
||||
// parse key exist error to duplciate ID error
|
||||
{errdupc, ErrDuplicateID},
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
|
@ -99,8 +99,10 @@ func Main() {
|
||||
if err != nil {
|
||||
switch err {
|
||||
case discovery.ErrDuplicateID:
|
||||
log.Fatalf("member %s has previously registered with discovery service (%s), but the data-dir (%s) on disk cannot be found.",
|
||||
cfg.name, cfg.durl, cfg.dir)
|
||||
log.Printf("member %q has previously registered with discovery service token (%s).", cfg.name, cfg.durl)
|
||||
log.Printf("But etcd could not find vaild cluster configuration in the given data dir (%s).", cfg.dir)
|
||||
log.Printf("Please check the given data dir path if the previous bootstrap succeeded")
|
||||
log.Printf("or use a new discovery token if the previous bootstrap failed.")
|
||||
default:
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user