Skip to content

remotes/docker: handle context cancellation in pushWriter.Commit - #14359

Open
DARSHANR007 wants to merge 1 commit into
containerd:mainfrom
DARSHANR007:docker-pusher-context-cancellation
Open

DARSHANR007 wants to merge 1 commit into
containerd:mainfrom
DARSHANR007:docker-pusher-context-cancellation

Conversation

@DARSHANR007

Copy link
Copy Markdown

Description

When pushing an image layer, pushWriter.Commit() waits on registry response channels without checking ctx.Done(). If the context is canceled or times out, Commit() hangs indefinitely until the connection drops.

This change:

  • Adds a case <-ctx.Done(): check to pushWriter.Commit() to return ctx.Err() promptly on cancellation or timeout.
  • Calls pw.Close() to abort active background pipes.
  • Drains and closes resp.Body (via io.Copy(io.Discard, resp.Body)) so http.Client can reuse keep-alive connections.
  • Adds comprehensive unit and edge-case tests covering cancellation, timeouts and concurrent races.

Fixes #14358

Copilot AI balanced review requested due to automatic review settings October 14, 2026 05:46
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Oct 14, 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 was unable to review this pull request because the user who requested the review has reached their quota limit.

When pushing an image, pushWriter.Commit waits on the registry response
without checking ctx.Done(). If the client cancels the operation or the
request times out, Commit hangs until the TCP connection drops.

Add a ctx.Done() check to the select block so we exit promptly on
cancellation or timeout. Also ensure any received response body is
drained and closed properly so http.Client can reuse the connection.

Signed-off-by: darsh <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 05:52
@DARSHANR007
DARSHANR007 force-pushed the docker-pusher-context-cancellation branch from f7d5cf4 to bae2ace Compare October 14, 2026 05:52

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@DARSHANR007

Copy link
Copy Markdown
Author

/retest

@kubernetes-prow

Copy link
Copy Markdown

@DARSHANR007: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@kubernetes-prow

Copy link
Copy Markdown

PR needs rebase.

Details

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.

This branch has not been deployed

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

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

remotes/docker: pushWriter.Commit blocks indefinitely when context is canceled

2 participants