Skip to content

Commit 77187d7

Browse files
committed
pkg/retry: retry 50{2,3,4} server errors
For quay.io it is quite common that if fails with 50{2,3,4} errors and trying again is often enough to fix them. As such it would be good if we retry them by default. Fixes #2299 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
1 parent 2908b07 commit 77187d7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/retry/retry.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import (
55
"io"
66
"math"
77
"net"
8+
"net/http"
89
"net/url"
910
"syscall"
1011
"time"
1112

13+
"github.com/containers/image/v5/docker"
1214
"github.com/docker/distribution/registry/api/errcode"
1315
errcodev2 "github.com/docker/distribution/registry/api/v2"
1416
"github.com/hashicorp/go-multierror"
@@ -81,6 +83,13 @@ func IsErrorRetryable(err error) bool {
8183
return false
8284
}
8385
return true
86+
case docker.UnexpectedHTTPStatusError:
87+
// Retry on 502, 502 and 503 http server errors, they appear to be quite common in the field.
88+
// https://github.com/containers/common/issues/2299
89+
if e.StatusCode >= http.StatusBadGateway && e.StatusCode <= http.StatusGatewayTimeout {
90+
return true
91+
}
92+
return false
8493
case *net.OpError:
8594
return IsErrorRetryable(e.Err)
8695
case *url.Error: // This includes errors returned by the net/http client.

0 commit comments

Comments
 (0)