Skip to content

Replay OCI blob bodies on upload retry - #34

Merged
CMGS merged 1 commit into
cocoonstack:mainfrom
zili-simular:fix/oci-blob-retry
Sep 24, 2026
Merged

CMGS merged 1 commit into
cocoonstack:mainfrom
zili-simular:fix/oci-blob-retry

Conversation

@zili-simular

Copy link
Copy Markdown
Contributor

Why the change

A transient registry upload failure can leave a streamed blob body at EOF, causing go-containerregistry's retry to send zero bytes instead of the declared content length, so this change preserves seekability through the upload contract and rewinds the body before every retry attempt.

Special things to note

  • The snapshot.Uploader interface now requires io.ReadSeeker for blob uploads; existing production callers already provide either *os.File or *bytes.Reader.
  • The regression test exercises the retry-relevant v1.Layer contract directly by fully consuming Compressed() twice and requiring the complete blob both times.

Change outline

Preserve replayability instead of erasing it at the uploader and registry boundaries.

 snapshot.Uploader.PutBlob(
-  body io.Reader,
+  body io.ReadSeeker,
 )
 
 OCIRegistry.PutBlob(
-  body io.Reader,
+  body io.ReadSeeker,
 )
 
 streamLayer
-  body io.Reader
+  body io.ReadSeeker

Rewind the same spooled file before each stream requested by go-containerregistry.

 snapshot.uploadSpooled
   write and hash blob into temporary file
   putBlobIfMissing
     seek temporary file to byte 0
     OCIRegistry.PutBlob
       remote.WriteLayer(streamLayer)
         streamLayer.Compressed
-          return body at its current offset
+          seek body to byte 0
+          return the complete body
         transient registry failure
         go-containerregistry retries
         streamLayer.Compressed
+          seek body to byte 0
+          return the complete body again

@zili-simular
zili-simular marked this pull request as ready for review September 24, 2026 10:37
@CMGS
CMGS merged commit ed18c45 into cocoonstack:main Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants