Skip to content

Commit 9b8f351

Browse files
committed
fix: handle errors in image push functions and increase timeout
1 parent 063fe18 commit 9b8f351

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

internal/sync/images.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package sync
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"slices"
78
"strings"
@@ -31,11 +32,23 @@ func checkRateLimit(err error) error {
3132
func push(ctx context.Context, image *structs.Image, desc *remote.Descriptor, dst string, tag string) error {
3233
return backoff.RetryNotify(func() error {
3334
if strings.HasPrefix(dst, "r2:") {
34-
return pushR2(ctx, image, desc, dst, tag)
35+
if err := pushR2(ctx, image, desc, dst, tag); err != nil {
36+
if errors.Is(err, remote.ErrSchema1) {
37+
return backoff.Permanent(err)
38+
}
39+
return err
40+
}
41+
return nil
3542
}
3643

3744
if strings.HasPrefix(dst, "s3:") {
38-
return pushS3(ctx, image, desc, dst, tag)
45+
if err := pushS3(ctx, image, desc, dst, tag); err != nil {
46+
if errors.Is(err, remote.ErrSchema1) {
47+
return backoff.Permanent(err)
48+
}
49+
return err
50+
}
51+
return nil
3952
}
4053

4154
pushAuth, _ := getAuth(image.GetRegistry(dst), image.GetRepository(dst))

internal/sync/s3.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func getS3Session(url string) (*s3.S3, *string, error) {
4141
Region: region,
4242
S3ForcePathStyle: aws.Bool(true),
4343
HTTPClient: &http.Client{
44-
Timeout: 60 * time.Second,
44+
Timeout: 300 * time.Second, // Some blobs are huge
4545
},
4646
})
4747
if err != nil {
@@ -141,7 +141,6 @@ func pushS3WithSession(ctx context.Context, s3Session *s3.S3, bucket *string, im
141141
if _, err := io.Copy(tmpFile, r); err != nil {
142142
return err
143143
}
144-
tmpFile.Seek(0, io.SeekStart)
145144

146145
if err := syncObject(
147146
ctx,

0 commit comments

Comments
 (0)