Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set more explicit error message when network config is missing in etcd #1606

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions subnet/etcd/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

var (
errTryAgain = errors.New("try again")
errKeyNotFound = errors.New("key not found")
errConfigNotFound = errors.New("flannel config not found in etcd store. Did you create your config using etcdv3 API?")
errNoWatchChannel = errors.New("no watch channel")
errSubnetAlreadyexists = errors.New("subnet already exists")
)
Expand Down Expand Up @@ -153,7 +153,7 @@ func (esr *etcdSubnetRegistry) getNetworkConfig(ctx context.Context) (string, er
return "", err
}
if len(resp.Kvs) == 0 {
return "", rpctypes.ErrGRPCKeyNotFound
return "", errConfigNotFound
}

return string(resp.Kvs[0].Value), nil
Expand Down Expand Up @@ -200,7 +200,7 @@ func (esr *etcdSubnetRegistry) getSubnet(ctx context.Context, sn ip.IP4Net, sn6
}

if len(resp.Kvs) == 0 {
return nil, 0, errKeyNotFound
return nil, 0, rpctypes.ErrGRPCKeyNotFound
}

ttlresp, err := esr.cli.TimeToLive(ctx, etcd.LeaseID(resp.Kvs[0].Lease))
Expand Down
2 changes: 1 addition & 1 deletion subnet/etcd/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestEtcdRegistry(t *testing.T) {
r, kvApi := newTestEtcdRegistry(t, ctx, client)

_, err := r.getNetworkConfig(ctx)
if err == nil {
if err != errConfigNotFound {
t.Fatal("Should hit error getting config")
}

Expand Down