Skip to content

remotes: revert closing fetch readers at EOF - #14194

Merged
mxpv merged 2 commits into
containerd:mainfrom
crazy-max:fix-fetch-retry-after-eof
Sep 19, 2026
Merged

mxpv merged 2 commits into
containerd:mainfrom
crazy-max:fix-fetch-retry-after-eof

Conversation

@crazy-max

@crazy-max crazy-max commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Revert #13438 to restore registry-cache upload retries, addressing the regression blocking BuildKit containerd v2.4.0 upgrade in moby/buildkit#7173 (comment). Closing the source reader at EOF prevents content.Copy from rewinding it when the destination writer requests a retry, causing uploads to fail with seek on closed reader.

The HTTP reader already closes its response body at EOF while remaining seekable, preserving CRI progress accounting before a slow commit without the generic wrapper. A separate commit adds regression tests for replaying uploads after HTTP 408, seeking after EOF, and closing the HTTP body exactly once before commit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The reader lifecycle change may regress non-seekable readers and CRI progress accounting.

Pull request overview

Fixes registry upload retries after EOF by preserving readers until content.Copy completes while retaining HTTP EOF cleanup.

Changes:

  • Removes generic close-on-EOF wrappers.
  • Adds upload retry regression coverage.
  • Tests HTTP body lifecycle and seekability.
File summaries
File Summary
core/remotes/handlers.go Defers reader closure; requires preserving EOF-close behavior for non-seekable readers.
core/remotes/docker/pusher_test.go Tests upload recovery after retryable responses.
core/remotes/docker/fetcher_test.go Tests HTTP EOF closure and commit timing.
Review details

Suppressed comments (1)

core/remotes/handlers.go:181

  • This changes the generic Fetcher contract for every non-HTTP/non-seekable reader: Close is now deferred until content.Copy returns, so a reader that reaches EOF can keep its underlying request/resource active while Commit blocks. The removed wrapper closed such readers at EOF (and the CRI progress accounting relies on that lifecycle). Preserve the EOF-close behavior for non-seekable readers, while leaving seekable readers usable for reset retries, or otherwise document and update all Fetcher implementations to provide equivalent semantics.
	// Keep the reader usable until Copy finishes: a writer may request a
	// reset after EOF, including while committing the content.
	defer rc.Close()

	return content.Copy(ctx, cw, rc, desc.Size, desc.Digest)
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@crazy-max
crazy-max marked this pull request as ready for review September 18, 2026 15:16
@thaJeztah thaJeztah added the cherry-pick/2.4.x Change to be cherry picked to release/2.4 label Sep 18, 2026
@thaJeztah

Copy link
Copy Markdown
Member

/cherry-pick release/2.4

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@thaJeztah: once the present PR merges, I will cherry-pick it on top of release/2.4 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release/2.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Comment thread core/remotes/docker/fetcher_test.go Outdated
require.NoError(t, err)
defer rc.Close()

for i := 0; i < 2; i++ {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case linters start to complain;

for i := range 2 {

@samuelkarp

Copy link
Copy Markdown
Member

Would you prefer this or to revert #13438 entirely? Based on #13438 (comment), the change in #13304 might have been sufficient to prevent the test flake anyway.

@samuelkarp

Copy link
Copy Markdown
Member

Okay, looking at the diff this does revert #13438. Can you change the commit structure slightly:

  • use git revert for a clean revert commit
  • add a second commit with your new test + the new comments

Verify that small and large layer uploads can be replayed after the registry consumes the body and returns HTTP 408.
This covers the fetch-to-pusher path used by BuildKit registry cache exports.

Check that HTTP readers close their response bodies at EOF while remaining seekable, and that the body is closed
exactly once before the destination writer commits.

Signed-off-by: CrazyMax <[email protected]>
Copilot AI review requested due to automatic review settings September 18, 2026 22:44
@crazy-max
crazy-max force-pushed the fix-fetch-retry-after-eof branch from d320648 to 0bdad46 Compare September 18, 2026 22:44
@crazy-max crazy-max changed the title remotes: preserve fetch readers for retries after EOF remotes: revert closing fetch readers at EOF Sep 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review issues were identified.

Review effort: Lite
Findings: None

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Sep 19, 2026

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mxpv
mxpv added this pull request to the merge queue Sep 19, 2026
Merged via the queue into containerd:main with commit 00d4724 Sep 19, 2026
96 of 98 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Sep 19, 2026
@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@thaJeztah: new pull request created: #14197

Details

In response to this:

/cherry-pick release/2.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/2.4.x Change to be cherry picked to release/2.4 size/L

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants