diff --git a/cache/remotecache/s3/s3.go b/cache/remotecache/s3/s3.go index 3b4e34048fc8..eb85ffd3e2dc 100644 --- a/cache/remotecache/s3/s3.go +++ b/cache/remotecache/s3/s3.go @@ -454,11 +454,14 @@ func (s3Client *s3Client) getManifest(ctx context.Context, key string, config *v return true, nil } -func (s3Client *s3Client) getReader(ctx context.Context, key string) (io.ReadCloser, error) { +func (s3Client *s3Client) getReader(ctx context.Context, key string, offset int64) (io.ReadCloser, error) { input := &s3.GetObjectInput{ Bucket: &s3Client.bucket, Key: &key, } + if offset > 0 { + input.Range = aws.String(fmt.Sprintf("bytes=%d-", offset)) + } output, err := s3Client.GetObject(ctx, input) if err != nil { @@ -588,7 +591,7 @@ func (s3Client *s3Client) touch(ctx context.Context, key string, size *int64) (e func (s3Client *s3Client) ReaderAt(ctx context.Context, desc ocispecs.Descriptor) (content.ReaderAt, error) { readerAtCloser := toReaderAtCloser(func(offset int64) (io.ReadCloser, error) { - return s3Client.getReader(ctx, s3Client.blobKey(desc.Digest)) + return s3Client.getReader(ctx, s3Client.blobKey(desc.Digest), offset) }) return &readerAt{ReaderAtCloser: readerAtCloser, size: desc.Size}, nil }