Skip to content

Commit

Permalink
Add UnavailableErrorCode (#1230)
Browse files Browse the repository at this point in the history
For registries that return a structured error containing UNAVAILABLE, we
weren't retrying because this error code isn't define in any specs;
however, it is used in the wild!
  • Loading branch information
jonjohnsonjr authored Jan 5, 2022
1 parent 7adcade commit 6c1bada
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/v1/remote/transport/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,18 @@ const (
UnsupportedErrorCode ErrorCode = "UNSUPPORTED"
TooManyRequestsErrorCode ErrorCode = "TOOMANYREQUESTS"
UnknownErrorCode ErrorCode = "UNKNOWN"

// This isn't defined by either docker or OCI spec, but is defined by docker/distribution:
// https://github.com/distribution/distribution/blob/6a977a5a754baa213041443f841705888107362a/registry/api/errcode/register.go#L60
UnavailableErrorCode ErrorCode = "UNAVAILABLE"
)

// TODO: Include other error types.
var temporaryErrorCodes = map[ErrorCode]struct{}{
BlobUploadInvalidErrorCode: {},
TooManyRequestsErrorCode: {},
UnknownErrorCode: {},
UnavailableErrorCode: {},
}

var temporaryStatusCodes = map[int]struct{}{
Expand Down
7 changes: 7 additions & 0 deletions pkg/v1/remote/transport/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ func TestTemporary(t *testing.T) {
}},
},
retry: true,
}, {
error: &Error{
Errors: []Diagnostic{{
Code: UnavailableErrorCode,
}},
},
retry: true,
}, {
error: &Error{
StatusCode: http.StatusInternalServerError,
Expand Down

0 comments on commit 6c1bada

Please sign in to comment.