Skip to content

Commit c061b3f

Browse files
authored
Retry more errors in remote.Write (#1019)
1 parent 4cdd086 commit c061b3f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: pkg/v1/remote/write.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"net/url"
2525
"strings"
2626
"sync/atomic"
27+
"syscall"
2728
"time"
2829

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

437438
ctx := w.context
438439

440+
shouldRetry := func(err error) bool {
441+
// Various failure modes here, as we're often reading from and writing to
442+
// the network.
443+
if retry.IsTemporary(err) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.EPIPE) {
444+
logs.Warn.Printf("retrying %v", err)
445+
return true
446+
}
447+
return false
448+
}
449+
439450
tryUpload := func() error {
440451
location, mounted, err := w.initiateUpload(from, mount)
441452
if err != nil {
@@ -495,7 +506,7 @@ func (w *writer) uploadOne(l v1.Layer) error {
495506
Steps: 3,
496507
}
497508

498-
return retry.Retry(tryUpload, retry.IsTemporary, backoff)
509+
return retry.Retry(tryUpload, shouldRetry, backoff)
499510
}
500511

501512
type withLayer interface {

0 commit comments

Comments
 (0)