Skip to content

cri: reset pull progress timer on idle→active transition - #13304

Merged
mxpv merged 1 commit into
containerd:mainfrom
dmcgowan:cri-pull-progress-idle-active-reset
Jun 2, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
dmcgowan:cri-pull-progress-idle-active-reset

Conversation

@dmcgowan

@dmcgowan dmcgowan commented Apr 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Fix a flake in TestCRIImagePullTimeout/HoldingContentOpenWriterWithLocalPull (example failure).
  • The CRI pull progress reporter resets lastSeenTimestamp whenever a tick observes activeReqs == 0, but never on the transition from idle to active. As a result, a request issued just after an idle period can be cancelled less than timeout after it was actually sent on the wire — its first byte has to arrive within whatever fraction of timeout was left on the timer captured during the previous idle tick.
  • Track the previous tick's activeReqs and reset the timer when we observe a 0→nonzero transition, so a newly-issued request always gets a full timeout window to produce its first byte.

In the failing CI run, the test held content.OpenWriter for the amd64 manifest, which kept activeReqs == 0 while the pull blocked on the writer. When the test released the writer and the pull issued the GET for the manifest, the auth handshake (401 → token endpoint → retry) at ghcr.io took longer than the shrunken window, and the reporter cancelled the pull with context canceled.

Test plan

  • go test -count=20 -run TestPullProgressReporter ./internal/cri/server/images/...
  • go build ./internal/cri/server/images/...
  • go vet ./internal/cri/server/images/...
  • CI green on TestCRIImagePullTimeout (especially the HoldingContentOpenWriter* subtests).

Copilot AI review requested due to automatic review settings April 28, 2026 02:23
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Apr 28, 2026
@dosubot dosubot Bot added area/cri Container Runtime Interface (CRI) kind/bug labels Apr 28, 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.

Pull request overview

Fixes a CRI image pull timeout flake by ensuring the pull progress reporter’s no-progress timer is reset when requests resume after an idle period, so newly-issued requests get a full timeout window to receive first bytes.

Changes:

  • Update pullProgressReporter to track the previous tick’s activeReqs and reset lastSeenTimestamp on an idle→active transition.
  • Add unit tests covering the basic cancel/no-cancel behavior of pullProgressReporter for stuck vs progressing requests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/cri/server/images/image_pull.go Reset the pull no-progress timer on idle→active transitions by tracking prevActiveReqs.
internal/cri/server/images/image_pull_test.go Add TestPullProgressReporter to validate cancellation for stuck requests and non-cancellation with byte progress.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dmcgowan
dmcgowan marked this pull request as draft April 28, 2026 02:51
Copilot AI review requested due to automatic review settings April 28, 2026 03:25
@dmcgowan
dmcgowan force-pushed the cri-pull-progress-idle-active-reset branch from 0454ce2 to 4cda43d Compare April 28, 2026 03:25
The pull progress reporter resets lastSeenTimestamp on every tick where
activeReqs == 0, but never on the transition to a non-zero count. When a
pull is held in content.OpenWriter (idle in HTTP terms) and then
unblocks, the next request can be cancelled less than `timeout` after it
was actually issued — its first byte must arrive within whatever fraction
of `timeout` remains on the timer captured during the previous idle
tick.

Track the previous tick's activeReqs and reset the timer on the 0→1
transition so a newly-issued request always gets a full timeout window
to produce its first byte. This deflakes
TestCRIImagePullTimeout/HoldingContentOpenWriterWithLocalPull, which
hits ghcr.io directly and can exceed the shrunken window during
auth handshakes in CI.

Signed-off-by: Derek McGowan <[email protected]>
@dmcgowan
dmcgowan force-pushed the cri-pull-progress-idle-active-reset branch from 4cda43d to 6c396d0 Compare April 29, 2026 00:25
Debugf("progress for image pull")

if activeReqs == 0 || bytesRead > lastSeenBytesRead {
// Reset the no-progress timer when idle, when bytes were

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.

The change looks good.

@dmcgowan
dmcgowan marked this pull request as ready for review April 30, 2026 23:37
@dmcgowan dmcgowan moved this from Needs Triage to Needs Reviewers in Pull Request Review Apr 30, 2026
@dmcgowan dmcgowan added the cherry-pick/2.3.x Change to be cherry picked to release/2.3 label Apr 30, 2026
@github-project-automation github-project-automation Bot moved this from Needs Reviewers to Review In Progress in Pull Request Review Jun 2, 2026
@samuelkarp
samuelkarp added this pull request to the merge queue Jun 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 2, 2026
@samuelkarp
samuelkarp added this pull request to the merge queue Jun 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 2, 2026
@samuelkarp
samuelkarp added this pull request to the merge queue Jun 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 2, 2026
@mxpv
mxpv added this pull request to the merge queue Jun 2, 2026
Merged via the queue into containerd:main with commit 83d9e66 Jun 2, 2026
54 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cri Container Runtime Interface (CRI) cherry-pick/2.3.x Change to be cherry picked to release/2.3 kind/bug size/M

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants