Repository navigation
fix: enable chunked blob upload for Azure ACR replication - #23016
Conversation
themavik
left a comment
There was a problem hiding this comment.
OR-ing policy CopyByChunk with adapter SupportedCopyByChunk fixes ACR without manual policy flags; test asserts task param. nit: adapters that set SupportedCopyByChunk but work fine monolithically may pay extra chunk round trips β confirm that is acceptable. nit: integration_test comment example uses a concrete azurecr hostname β scrub if you do not want a real-looking name in-tree.
|
Hi @xrkolovos , Thanks for contributing to our community! Due to limited resource for use to test replication on ACR, Could you help to have a demo record or documentation reference for us that would increase confidence for us to adopt this adapter enhancement. Best, |
themavik
left a comment
There was a problem hiding this comment.
copyByChunk := policy CopyByChunk OR adapter SupportedCopyByChunk matches ACR-style destinations without flipping the policy bit alone. TestCopyByChunkAutoEnabled asserts Create runs with chunking when Info sets SupportedCopyByChunk true.
|
Hi @MinerYang, thanks for the review! The PR includes an integration test ( The test validates the exact replication flow: it first demonstrates that a monolithic 25MB push fails with HTTP 413 (confirming the original issue), then shows the same blob succeeding via 5MB chunked uploads. You can reproduce it by setting Let me know if you'd like a screen recording as well or if the test output is sufficient. |
|
hello, @MinerYang can you provide some feedback? are you ok with my latest reply? |
|
Hello @chlins and @MinerYang , Just following up on this pull request. We need it for our system, and I would really appreciate your feedback when you have a chance. Thank you very much. |
|
@wy65701436 @stonezdj can you help with the merge in this issue? |
Per review feedback on goharbor#23016, drop the auto-enabling of chunked upload when the destination adapter declares SupportedCopyByChunk. Whether a replication uses chunked upload is the user's choice via the replication policy setting; an adapter declaring support must not force the behavior, as that would also silently change the default for Harbor-to-Harbor replications. The Azure ACR adapter still declares SupportedCopyByChunk: true, which exposes the "Copy by chunk" option in the replication rule UI for ACR endpoints, and PushBlobChunk() still sets req.ContentLength so chunked uploads work against ACR when the user enables the option. Also remove TestCopyByChunkAutoEnabled, which validated the removed behavior. Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr>
4536d3e to
929877f
Compare
Per review feedback on goharbor#23016, drop the auto-enabling of chunked upload when the destination adapter declares SupportedCopyByChunk. Whether a replication uses chunked upload is the user's choice via the replication policy setting; an adapter declaring support must not force the behavior, as that would also silently change the default for Harbor-to-Harbor replications. The Azure ACR adapter still declares SupportedCopyByChunk: true, which exposes the "Copy by chunk" option in the replication rule UI for ACR endpoints, and PushBlobChunk() still sets req.ContentLength so chunked uploads work against ACR when the user enables the option. Also remove TestCopyByChunkAutoEnabled, which validated the removed behavior. Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr>
Codecov Reportβ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23016 +/- ##
==========================================
- Coverage 66.12% 66.11% -0.01%
==========================================
Files 1073 1073
Lines 116882 116883 +1
Branches 2959 2959
==========================================
- Hits 77283 77280 -3
- Misses 35320 35326 +6
+ Partials 4279 4277 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Enables chunked/resumable blob uploads for Azure ACR replication by (1) advertising the adapter capability so the UI can enable the option for ACR endpoints and (2) ensuring the registry client sends a proper Content-Length for each uploaded chunk (avoiding Azure ACRβs rejection of Transfer-Encoding: chunked).
Changes:
- Declare
SupportedCopyByChunk: truein the Azure ACR adapterInfo(). - Set
req.ContentLengthinPushBlobChunk()so Go emits a realContent-Lengthheader for each chunk. - Add an opt-in (env-gated) integration test that uploads a 25MB blob in 5MB chunks to a live ACR.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/pkg/registry/client.go |
Ensures chunk uploads use Content-Length via req.ContentLength (avoids Go sending chunked transfer encoding). |
src/pkg/reg/adapter/azurecr/adapter.go |
Advertises ACR adapter support for βCopy by chunkβ. |
src/pkg/reg/adapter/azurecr/adapter_test.go |
Extends unit coverage to assert the new capability flag is set. |
src/pkg/reg/adapter/azurecr/integration_test.go |
Adds an env-gated integration test validating chunked uploads against a real ACR instance. |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@xrkolovos I've targeted it to v2.16, so please resolve the PR and copilot comments. |
Head branch was pushed to by a user without write access
When replicating images from Harbor to Azure Container Registry, blob uploads larger than ~20MB fail with HTTP 413 (Request Entity Too Large). Root cause analysis revealed three issues: 1. The Azure ACR adapter did not declare SupportedCopyByChunk in its Info() method, so the replication flow always used monolithic (single PUT) uploads for ACR destinations. 2. The copy flow only checked the policy-level CopyByChunk flag and ignored the destination adapter's declared capability. This meant even if an adapter declared chunk support, users had to manually enable it per replication policy. 3. The registry client's PushBlobChunk() set Content-Length via req.Header.Set() but did not set req.ContentLength on the http.Request struct. Go's HTTP client ignores manually set Content-Length headers and relies on req.ContentLength to decide between Content-Length and Transfer-Encoding: chunked. As a result, Go sent the request with Transfer-Encoding: chunked (HTTP-level), which Azure ACR rejects with CONTENT_LENGTH_INVALID. Changes: - Set SupportedCopyByChunk: true in the Azure ACR adapter's Info() - Auto-enable chunked upload in the copy flow when the destination adapter declares support via SupportedCopyByChunk - Set req.ContentLength in PushBlobChunk() to ensure Go sends a proper Content-Length header instead of Transfer-Encoding: chunked Validated with an integration test that performs a real 25MB chunked blob upload (5 x 5MB chunks) against a live Azure ACR instance. Fixes goharbor#23015 Related: goharbor#21640 Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr>
Per review feedback on goharbor#23016, drop the auto-enabling of chunked upload when the destination adapter declares SupportedCopyByChunk. Whether a replication uses chunked upload is the user's choice via the replication policy setting; an adapter declaring support must not force the behavior, as that would also silently change the default for Harbor-to-Harbor replications. The Azure ACR adapter still declares SupportedCopyByChunk: true, which exposes the "Copy by chunk" option in the replication rule UI for ACR endpoints, and PushBlobChunk() still sets req.ContentLength so chunked uploads work against ACR when the user enables the option. Also remove TestCopyByChunkAutoEnabled, which validated the removed behavior. Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr>
Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr>
- move the ACR chunked upload integration test into adapter_test.go - drop redundant Content-Length header now that req.ContentLength is set - fix documented go test command path (run from the src module root) - use a unique repository name per test run to avoid collisions - add best-effort blob cleanup via t.Cleanup Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr>
Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr>
9a9f629 to
40b4c6a
Compare
|
thanks @xrkolovos , the code change looks good to me, cc @Vad1mo |
Upstream-PR: goharbor/harbor#23016 Upstream-Author: @xrkolovos Co-authored-by: Prasanth Baskar <bupdprasanth@gmail.com> Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr> Signed-off-by: Prasanth Baskar <bupdprasanth@gmail.com>
Upstream-PR: goharbor/harbor#23016 Upstream-Author: @xrkolovos Co-authored-by: Prasanth Baskar <bupdprasanth@gmail.com> Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr> Signed-off-by: Prasanth Baskar <bupdprasanth@gmail.com>
Upstream-PR: goharbor/harbor#23016 Upstream-Author: @xrkolovos Co-authored-by: Prasanth Baskar <bupdprasanth@gmail.com> Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr> Signed-off-by: Prasanth Baskar <bupdprasanth@gmail.com>
Upstream-PR: goharbor/harbor#23016 Upstream-Author: @xrkolovos Co-authored-by: Prasanth Baskar <bupdprasanth@gmail.com> Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr> Signed-off-by: Prasanth Baskar <bupdprasanth@gmail.com>
Upstream-PR: goharbor/harbor#23016 Upstream-Author: @xrkolovos Co-authored-by: Prasanth Baskar <bupdprasanth@gmail.com> Signed-off-by: Chrysostomos Kolovos <xrkolovos@egritosgroup.gr> Signed-off-by: Prasanth Baskar <bupdprasanth@gmail.com>
Summary
Fixes #23015 β Azure ACR replication fails with HTTP 413 for blob layers larger than ~20MB.
Related: #21640
Root cause
Two issues were identified:
Missing adapter capability declaration β The Azure ACR adapter's
Info()method did not setSupportedCopyByChunk: true. Because the capability was not declared, the "Copy by chunk" option was not available in the replication rule UI for ACR endpoints, so replications always used monolithic (single PUT) blob uploads β which ACR rejects with HTTP 413 for blobs larger than ~20MB.req.ContentLengthnot set inPushBlobChunk()β The registry client setContent-Lengthviareq.Header.Set(), but Go's HTTP client ignores manually setContent-Lengthheaders. It uses thereq.ContentLengthstruct field to decide between sending aContent-Lengthheader or usingTransfer-Encoding: chunked. Without settingreq.ContentLength, Go sent blob chunks with HTTP chunked transfer encoding, which Azure ACR rejects withCONTENT_LENGTH_INVALID(400).Changes
src/pkg/reg/adapter/azurecr/adapter.goSupportedCopyByChunk: trueinInfo()src/pkg/registry/client.goreq.ContentLengthinPushBlobChunk()to ensure proper Content-Length headerTesting
integration_test.gothat performs a real 25MB chunked blob upload (5 Γ 5MB chunks) against a live Azure Container Registry instance. The test is skipped unlessACR_URL,ACR_USER, andACR_PASSenvironment variables are set.How to run integration test
ACR_URL=https://yourregistry.azurecr.io ACR_USER=admin ACR_PASS=secret \ go test -v -run TestChunkedUploadToACR ./src/pkg/reg/adapter/azurecr/...