Skip to content

Commit

Permalink
Retry more errors in remote.Write (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjohnsonjr committed May 17, 2021
1 parent 4cdd086 commit c061b3f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/v1/remote/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"net/url"
"strings"
"sync/atomic"
"syscall"
"time"

"github.com/google/go-containerregistry/internal/redact"
Expand Down Expand Up @@ -436,6 +437,16 @@ func (w *writer) uploadOne(l v1.Layer) error {

ctx := w.context

shouldRetry := func(err error) bool {
// Various failure modes here, as we're often reading from and writing to
// the network.
if retry.IsTemporary(err) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.EPIPE) {
logs.Warn.Printf("retrying %v", err)
return true
}
return false
}

tryUpload := func() error {
location, mounted, err := w.initiateUpload(from, mount)
if err != nil {
Expand Down Expand Up @@ -495,7 +506,7 @@ func (w *writer) uploadOne(l v1.Layer) error {
Steps: 3,
}

return retry.Retry(tryUpload, retry.IsTemporary, backoff)
return retry.Retry(tryUpload, shouldRetry, backoff)
}

type withLayer interface {
Expand Down

0 comments on commit c061b3f

Please sign in to comment.