Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Adds resumable proxy-cache blob fetching and digest verification before local caching.
Changes:
- Adds bounded retries using HTTP range requests.
- Verifies cached blob digests.
- Adds retry and corruption tests.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/controller/proxy/blobretry.go |
Implements retry and verification readers. |
src/controller/proxy/blobretry_test.go |
Tests reader behavior. |
src/controller/proxy/controller.go |
Integrates retries and verification. |
src/controller/proxy/controller_test.go |
Tests controller cache population. |
src/controller/proxy/manifestcache.go |
Protects manifest dependency caching. |
src/controller/proxy/manifestcache_test.go |
Tests dependency blob handling. |
src/controller/proxy/remote.go |
Adds ranged blob reads. |
src/testing/controller/proxy/remote_interface.go |
Extends the remote mock. |
Files not reviewed (1)
- src/testing/controller/proxy/remote_interface.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c177a8d to
2a476c7
Compare
|
What negative effect might a retry have on rate limits? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23601 +/- ##
==========================================
+ Coverage 74.24% 74.29% +0.05%
==========================================
Files 1096 1097 +1
Lines 103602 103701 +99
Branches 3079 3079
==========================================
+ Hits 76918 77046 +128
+ Misses 26314 26287 -27
+ Partials 370 368 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Good question. Two things worth separating here: How much extra load can retry actually add? It only ever triggers on a genuinely interrupted connection (dropped/reset mid-transfer), never on a normal successful pull, and it's bounded to at most 3 extra attempts per interrupted blob with exponential backoff (1s/2s/4s) - not a multiplier on regular traffic. I'd actually argue this reduces aggregate upstream load in the failure case: today, an interrupted blob fails the whole pull outright, so the kubelet/docker client has to retry the entire image (manifest + every blob) from scratch. This resumes just the missing tail of the one interrupted blob via a Range request instead, which is strictly less upstream traffic than an outer full-image retry. Where you're right that there was a real gap: if a resume attempt itself got rate-limited (429), the code was treating that the same as any other transient error and retrying it with the same 1-4s backoff - which won't help against a real rate limit (those typically need a much longer cool-down) and just adds more rejected requests. Fixed that in bbc3c78: a rate-limited resume now gives up immediately instead of consuming the rest of the retry budget, using the existing errors.IsRateLimitError check (same one already used elsewhere in this file for manifest 429 handling). Given the above I'd rather not add a feature flag - the behavior is already bounded and opt-out-shaped (only fires on failure), and a flag adds real config/test surface for a fairly narrow edge case. Happy to reconsider if you still think it's warranted, though. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- src/testing/controller/proxy/remote_interface.go: Generated file
Comments suppressed due to low confidence (1)
src/pkg/registry/client.go:414
- Validate the complete
Content-Range, not only its start.PullBlobChunkis also used bycopyBlobByChunk(src/controller/replication/transfer/image/transfer.go:429-440), so a server can currently answer a request forbytes=0-4with206 Content-Range: bytes 0-10/11; this check accepts the full body even though it violates that caller's chunk contract. Parse and require the returned end to equalend(and, whenblobSizeis known, the total to equal it), with a regression test for a matching start but mismatched end.
cr := resp.Header.Get("Content-Range")
got, crErr := parseContentRangeStart(cr)
if crErr != nil || got != start {
defer resp.Body.Close()
return 0, nil, fmt.Errorf("registry returned Content-Range %q for requested range bytes=%d-%d, refusing to treat it as that chunk", cr, start, end)
bbc3c78 to
586ab1f
Compare
|
All the comments in the code and the commit messages are very verbose, I can condense a lot of that after initial review I think |
|
This PR is being marked stale due to a period of inactivty. If this PR is still relevant, please comment or remove the stale label. Otherwise, this PR will close in 30 days. |
|
Not stale |
|
can you merge it faster, please, it hurts T_T |
|
I'll rebase so it's mergable again. I would love a review. |
be2ae06 to
47b0e65
Compare
| // cache: interrupted reads are resumed, and the content is verified against | ||
| // desc.Digest so a corrupted blob fails the push instead of being committed. | ||
| // The copy is detached from any pulling client, hence its own context. | ||
| func openCacheBlobReader(r RemoteInterface, remoteRepo string, desc distribution.Descriptor) (io.ReadCloser, error) { |
There was a problem hiding this comment.
Suggest to use openVerifiedBlobReader as the function name, because it is read and verify.
47b0e65 to
6e372e3
Compare
…st before caching The proxy cache fetched every blob with a single GET and no retry, so a connection dropped mid-stream failed the pull and left the blob uncached. Wrap the upstream body in a reader that, on a mid-stream read error or a premature EOF, resumes from the last byte read with a range request (RemoteInterface.BlobReaderAt, backed by the existing PullBlobChunk). It resumes at most 3 times with exponential backoff, gives up on a 429, and stops once the caller's context is canceled or the reader is closed. The client-facing fetch and both cache-populate fetches use it. PullBlobChunk now rejects a response that isn't the requested range - a 200 for a partial range, or a 206 whose Content-Range starts elsewhere - because splicing it in at the requested offset would corrupt the blob. The cache-populate fetches also verify the content against the blob digest, so a corrupted body fails the push to local storage. Fixes goharbor#23600 Signed-off-by: Oscar Wieman <oscar@oscarr.nl>
6e372e3 to
94df648
Compare
Comprehensive Summary of your change
The proxy cache fetches each upstream blob with a single GET. If that connection drops mid-stream, the pull fails and the blob is not cached (#23600).
What changes
PullBlobChunkchecks what it got back. It now rejects a 200 for a partial range and a 206 whoseContent-Rangestarts at a different offset, because splicing either in would corrupt the blob. This function is shared with chunked replication, and it is the only change outside the proxy package.A pull that succeeds first time makes no extra upstream requests. No config, API or docs change.
Where to look
About 280 of the 780 added lines are code; the rest is tests and a regenerated mock. The logic is in
src/controller/proxy/blobretry.go, and thePullBlobChunkcheck is insrc/pkg/registry/client.go.Issue being fixed
Fixes #23600
Please indicate you've done the following: