Remove backoff for http challenge
Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
parent
f92b03a44d
commit
84516f962d
1 changed files with 8 additions and 27 deletions
|
@ -11,10 +11,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cenkalti/backoff/v4"
|
|
||||||
"github.com/go-acme/lego/v4/challenge/http01"
|
"github.com/go-acme/lego/v4/challenge/http01"
|
||||||
"github.com/traefik/traefik/v2/pkg/log"
|
"github.com/traefik/traefik/v2/pkg/log"
|
||||||
"github.com/traefik/traefik/v2/pkg/safe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChallengeHTTP HTTP challenge provider implements challenge.Provider.
|
// ChallengeHTTP HTTP challenge provider implements challenge.Provider.
|
||||||
|
@ -105,35 +103,18 @@ func (c *ChallengeHTTP) getTokenValue(ctx context.Context, token, domain string)
|
||||||
logger := log.FromContext(ctx)
|
logger := log.FromContext(ctx)
|
||||||
logger.Debugf("Retrieving the ACME challenge for %s (token %q)...", domain, token)
|
logger.Debugf("Retrieving the ACME challenge for %s (token %q)...", domain, token)
|
||||||
|
|
||||||
var result []byte
|
|
||||||
|
|
||||||
operation := func() error {
|
|
||||||
c.lock.RLock()
|
c.lock.RLock()
|
||||||
defer c.lock.RUnlock()
|
defer c.lock.RUnlock()
|
||||||
|
|
||||||
if _, ok := c.httpChallenges[token]; !ok {
|
if _, ok := c.httpChallenges[token]; !ok {
|
||||||
return fmt.Errorf("cannot find challenge for token %q (%s)", token, domain)
|
logger.Errorf("Cannot retrieve the ACME challenge for %s (token %q)", domain, token)
|
||||||
}
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
result, ok = c.httpChallenges[token][domain]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("cannot find challenge for %s (token %q)", domain, token)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
notify := func(err error, time time.Duration) {
|
result, ok := c.httpChallenges[token][domain]
|
||||||
logger.Errorf("Error getting challenge for token retrying in %s", time)
|
if !ok {
|
||||||
}
|
logger.Errorf("Cannot retrieve the ACME challenge for %s (token %q)", domain, token)
|
||||||
|
return nil
|
||||||
ebo := backoff.NewExponentialBackOff()
|
|
||||||
ebo.MaxElapsedTime = 60 * time.Second
|
|
||||||
err := backoff.RetryNotify(safe.OperationWithRecover(operation), ebo, notify)
|
|
||||||
if err != nil {
|
|
||||||
logger.Errorf("Cannot retrieve the ACME challenge for %s (token %q): %v", domain, token, err)
|
|
||||||
return []byte{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue