1
0
Fork 0

Ignore ErrKeyNotFound error for the KV provider

This commit is contained in:
Yakun Sun 2023-09-25 22:38:07 +08:00 committed by GitHub
parent c3880a69ca
commit 173154cf59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 88 additions and 0 deletions

View file

@ -136,6 +136,16 @@ func (p *Provider) watchKv(ctx context.Context, configurationChan chan<- dynamic
func (p *Provider) buildConfiguration(ctx context.Context) (*dynamic.Configuration, error) {
pairs, err := p.kvClient.List(ctx, p.RootKey, nil)
if err != nil {
if errors.Is(err, store.ErrKeyNotFound) {
// This empty configuration satisfies the pkg/server/configurationwatcher.go isEmptyConfiguration func constraints,
// and will not be discarded by the configuration watcher.
return &dynamic.Configuration{
HTTP: &dynamic.HTTPConfiguration{
Routers: make(map[string]*dynamic.Router),
},
}, nil
}
return nil, err
}