Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions internal/pkg/mirror/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mirror

import (
"context"
"crypto/tls"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -229,13 +230,23 @@ func (o *Mirror) copy(ctx context.Context, src, dest string, opts *CopyOptions)
// Custom implementation to extend `containers/common/pkg/retry.retry`
func isErrorRetryable(err error) bool {
var httpError docker.UnexpectedHTTPStatusError
var tlsErr tls.AlertError
switch {
case err == nil:
return false
case errors.Is(err, context.DeadlineExceeded):
return true
case errors.Is(err, context.Canceled):
return false
case errors.Is(err, io.ErrUnexpectedEOF):
return true
case errors.As(err, &tlsErr):
// Go's crypto/tls does not export alert code constants, so we cannot
// distinguish transient server-side errors from systematic ones. In
// practice, any systematic TLS failures (bad cert, version mismatch,
// etc.) are likely to occur before we get to the point of copying
// blobs, so we won't get here.
return true
case errors.As(err, &httpError):
// Retry on 500-504 server errors, they appear to be quite common in the field
// We duplicate this here because older versions of oc-mirror cannot bump containers/common given Golang version restrictions
Expand Down