Repository navigation
[Backport v2] fix(retry): retry on connection reset by peer and unexpected EOF - #1570
Merged
TerryHowe merged 1 commit intoOct 13, 2026
Conversation
…s-project#1567) net/http never retries a request that failed on a fresh connection, so a single reset from a registry fails the whole operation although the retry policy is bounded and RoundTrip already rewinds request bodies. Treat syscall.ECONNRESET and io.ErrUnexpectedEOF as retryable in DefaultPredicate, next to the dial timeout. ECONNREFUSED, a bare io.EOF and unrelated errors are unchanged. Backport of oras-project#1567 to v2; tests adapted to this branch's test layout. (cherry picked from commit 055f8d1) Signed-off-by: Idan Rahamim <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
idan-rahamim-lendbuzz
requested review from
TerryHowe,
Wwwsylvia,
sabre1041 and
shizhMSFT
as code owners
October 13, 2026 10:53
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v2 #1570 +/- ##
==========================================
+ Coverage 89.04% 89.09% +0.04%
==========================================
Files 64 64
Lines 4948 4950 +2
==========================================
+ Hits 4406 4410 +4
+ Misses 533 531 -2
Partials 9 9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
Thanks! |
This was referenced Oct 16, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #1567 to
v2.retry.DefaultPredicateretries 5xx, 429, 408 and dial timeouts, but returns a connection reset by peer (syscall.ECONNRESET) or an unexpected EOF (io.ErrUnexpectedEOF) as is. Go'snet/httpdeliberately never retries a request that failed on a fresh connection, and the first request to a registry always is one, so a single reset (seen with AWS ECR) fails the whole operation although the policy is bounded andRoundTripalready rewinds request bodies. With this fix both are retried like a dial timeout;ECONNREFUSED, a bareio.EOFand unrelated errors are unchanged.Helm pins
oras.land/oras-go/v2, which is why this needs to be onv2.Cherry-pick
policy.gois the merged change as is: the hunks apply cleanly, sincev2's import block andDefaultPredicateare identical tomain's before the fix. The tests could not be cherry-picked: onv2,policy_test.gohas noTest_GenericPolicy_Retry*tables andclient_test.gohas noTest_Client_RetryAfterHonored, so the same coverage is added in this branch's layout: a table-drivenTest_DefaultPredicate(reset and unexpected EOF retried;ECONNREFUSEDand an unrelated error passed through) andTest_Client_RetryOnConnectionReset, identical tomain's (anhttptestserver that resets the first connection withSetLinger(0)and serves 200 on the second attempt; skipped on Windows, where a reset surfaces asWSAECONNRESET). The commit message records the adaptation below thecherry picked fromline.Tests
On
v2without the fix, the new tests fail:With the fix,
go test -race ./registry/remote/...passes,gofmtandgo vetare clean onregistry/remote/retry, and the new predicate lines are covered byTest_DefaultPredicatealone, so patch coverage holds where the client test is skipped.Test_Client_RetryOnConnectionResetpassed 20/20 with-race.Refs #1566
🤖 Generated with Claude Code