Improve provider logs

This commit is contained in:
Ludovic Fernandez 2022-11-30 09:50:05 +01:00 committed by GitHub
parent 0d81fac3fc
commit c57876c116
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 22 additions and 26 deletions

View file

@ -233,12 +233,12 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
}
notify := func(err error, time time.Duration) {
logger.Error().Err(err).Msgf("Provider connection error, retrying in %s", time)
logger.Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation), backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), ctxLog), notify)
if err != nil {
logger.Error().Err(err).Msg("Cannot connect to consul catalog server")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
})

View file

@ -329,11 +329,11 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
}
notify := func(err error, time time.Duration) {
logger.Error().Err(err).Msgf("Provider connection error, retrying in %s", time)
logger.Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation), backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), ctxLog), notify)
if err != nil {
logger.Error().Err(err).Msg("Cannot connect to docker server")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
})

View file

@ -183,11 +183,11 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
}
notify := func(err error, time time.Duration) {
logger.Error().Err(err).Msgf("Provider connection error, retrying in %s", time)
logger.Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation), backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), routineCtx), notify)
if err != nil {
logger.Error().Err(err).Msg("Cannot connect to Provider api")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
})

View file

@ -97,11 +97,11 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
}
notify := func(err error, time time.Duration) {
logger.Error().Err(err).Msgf("Provider connection error, retrying in %s", time)
logger.Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation), backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), ctxLog), notify)
if err != nil {
logger.Error().Err(err).Msg("Cannot connect to server endpoint")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
})

View file

@ -146,7 +146,7 @@ func TestProvider_decodeConfiguration(t *testing.T) {
},
{
desc: "should return the decoded dynamic configuration",
configData: []byte("{\"tcp\":{\"routers\":{\"foo\":{}}}}"),
configData: []byte(`{"tcp":{"routers":{"foo":{}}}}`),
expConfig: &dynamic.Configuration{
HTTP: &dynamic.HTTPConfiguration{
Routers: make(map[string]*dynamic.Router),

View file

@ -168,11 +168,11 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
}
notify := func(err error, time time.Duration) {
logger.Error().Err(err).Msgf("Provider connection error, retrying in %s", time)
logger.Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation), backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), ctxPool), notify)
if err != nil {
logger.Error().Err(err).Msg("Cannot connect to Provider")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
})

View file

@ -162,11 +162,11 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
}
notify := func(err error, time time.Duration) {
logger.Error().Err(err).Msgf("Provider connection error, retrying in %s", time)
logger.Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation), backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), ctxPool), notify)
if err != nil {
logger.Error().Err(err).Msg("Cannot connect to Provider")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
})

View file

@ -169,12 +169,12 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
}
notify := func(err error, time time.Duration) {
logger.Error().Err(err).Msgf("Provider connection error, retrying in %s", time)
logger.Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation), backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), ctxPool), notify)
if err != nil {
logger.Error().Err(err).Msg("Cannot connect to Provider")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
})

View file

@ -85,7 +85,7 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
err := p.watchKv(ctxLog, configurationChan)
if err != nil {
logger.Error().Err(err).Msg("Cannot watch KV store")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
})
@ -124,15 +124,11 @@ func (p *Provider) watchKv(ctx context.Context, configurationChan chan<- dynamic
}
notify := func(err error, time time.Duration) {
log.Ctx(ctx).Error().Err(err).Msgf("KV connection error, retrying in %s", time)
log.Ctx(ctx).Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation),
return backoff.RetryNotify(safe.OperationWithRecover(operation),
backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), ctx), notify)
if err != nil {
return fmt.Errorf("cannot connect to KV server: %w", err)
}
return nil
}
func (p *Provider) buildConfiguration(ctx context.Context) (*dynamic.Configuration, error) {

View file

@ -192,11 +192,11 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
}
notify := func(err error, time time.Duration) {
logger.Error().Err(err).Msgf("Provider connection error, retrying in %s", time)
logger.Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation), backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), ctx), notify)
if err != nil {
logger.Error().Err(err).Msg("Cannot connect to Provider server")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
return nil
}

View file

@ -140,11 +140,11 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
}
notify := func(err error, time time.Duration) {
logger.Error().Err(err).Msgf("Provider connection error, retrying in %s", time)
logger.Error().Err(err).Msgf("Provider error, retrying in %s", time)
}
err := backoff.RetryNotify(safe.OperationWithRecover(operation), backoff.WithContext(job.NewBackOff(backoff.NewExponentialBackOff()), ctxLog), notify)
if err != nil {
logger.Error().Err(err).Msg("Cannot connect to Provider server")
logger.Error().Err(err).Msg("Cannot retrieve data")
}
})