mirror of
https://github.com/containers/skopeo.git
synced 2025-09-06 01:00:43 +00:00
Bump github.com/containers/common from 0.20.3 to 0.21.0
Bumps [github.com/containers/common](https://github.com/containers/common) from 0.20.3 to 0.21.0. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.20.3...v0.21.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
committed by
Daniel J Walsh
parent
c4998ebf3f
commit
8767e73fe9
12
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
12
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
@@ -2,6 +2,7 @@ package retry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"math"
|
||||
"net"
|
||||
"net/url"
|
||||
@@ -17,7 +18,8 @@ import (
|
||||
|
||||
// RetryOptions defines the option to retry
|
||||
type RetryOptions struct {
|
||||
MaxRetry int // The number of times to possibly retry
|
||||
MaxRetry int // The number of times to possibly retry
|
||||
Delay time.Duration // The delay to use between retries, if set
|
||||
}
|
||||
|
||||
// RetryIfNecessary retries the operation in exponential backoff with the retryOptions
|
||||
@@ -25,6 +27,9 @@ func RetryIfNecessary(ctx context.Context, operation func() error, retryOptions
|
||||
err := operation()
|
||||
for attempt := 0; err != nil && isRetryable(err) && attempt < retryOptions.MaxRetry; attempt++ {
|
||||
delay := time.Duration(int(math.Pow(2, float64(attempt)))) * time.Second
|
||||
if retryOptions.Delay != 0 {
|
||||
delay = retryOptions.Delay
|
||||
}
|
||||
logrus.Infof("Warning: failed, retrying in %s ... (%d/%d)", delay, attempt+1, retryOptions.MaxRetry)
|
||||
select {
|
||||
case <-time.After(delay):
|
||||
@@ -58,7 +63,10 @@ func isRetryable(err error) bool {
|
||||
return true
|
||||
case *net.OpError:
|
||||
return isRetryable(e.Err)
|
||||
case *url.Error:
|
||||
case *url.Error: // This includes errors returned by the net/http client.
|
||||
if e.Err == io.EOF { // Happens when a server accepts a HTTP connection and sends EOF
|
||||
return true
|
||||
}
|
||||
return isRetryable(e.Err)
|
||||
case syscall.Errno:
|
||||
return e != syscall.ECONNREFUSED
|
||||
|
Reference in New Issue
Block a user