Skip to content

fix: synchronize gc plugin stops before metadata plugin closes - #13353

Open
austinvazquez wants to merge 2 commits into
containerd:mainfrom
austinvazquez:stop-gc-on-shutdown
Open

austinvazquez wants to merge 2 commits into
containerd:mainfrom
austinvazquez:stop-gc-on-shutdown

Conversation

@austinvazquez

@austinvazquez austinvazquez commented May 6, 2026 •

Copy link
Copy Markdown
Member

Issue

Follow-up to #13348

This change synchronizes the gc scheduler completes all collections before metadata plugin is closed during server shutdown.

Additional context

  • panic: Log in goroutine after TestCRIImagePullTimeout/SlowCommitWriterWithLocalPull has completed: time="2026-06-11T17:36:01.695875750Z" level=error msg="failed to finish collection context" func="metadata.(*gcContext).finish.func1" file="/home/runner/work/containerd/containerd/core/metadata/gc.go:453" error="readdirent /tmp/TestCRIImagePullTimeoutSlowCommitWriterWithLocalPull796840355/001/state/io.containerd.mount-manager.v1.bolt/t/.: no such file or directory" testcase=TestCRIImagePullTimeout/SlowCommitWriterWithLocalPull type=10

From https://github.com/containerd/containerd/actions/runs/27363955475/job/80859027083, commit 449d5ce adds synchronization to CRI integration test to close all initialized plugins before the containerd state directory is cleaned up. Additional protection like mount manager no error on directory not found to be considered separately.

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

This PR is a follow-up to #13348 to ensure containerd shutdown does not close the metadata DB while the GC scheduler may still be running a collection. It does so by making the GC scheduler plugin implement io.Closer and blocking shutdown until the scheduler run loop exits.

Changes:

  • Add a done signal to the GC scheduler and implement Close() to wait for the run loop to stop.
  • Update the scheduler run loop to close done on exit.
  • Add a unit test asserting Close() blocks until an in-progress GC completes and the run loop exits.

Reviewed changes

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

File Description
plugins/gc/scheduler.go Adds done signaling and a blocking Close() intended to serialize shutdown vs. in-flight GC.
plugins/gc/scheduler_test.go Adds a new test covering Close() waiting behavior during an in-flight collection.

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

Comment thread plugins/gc/scheduler.go Resolved
Comment thread plugins/gc/scheduler_test.go Resolved

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

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

Comment thread plugins/gc/scheduler.go Resolved
Comment thread plugins/gc/scheduler_test.go Resolved
Copilot AI review requested due to automatic review settings June 12, 2026 15:30

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@austinvazquez
austinvazquez marked this pull request as ready for review June 12, 2026 18:48
Copilot AI review requested due to automatic review settings June 12, 2026 18:48

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread plugins/gc/scheduler_test.go Resolved
Comment thread plugins/gc/scheduler_test.go Resolved
@austinvazquez

Copy link
Copy Markdown
Member Author

I opened #13588 to resolve the flaky test on Windows that appeared in CI on this PR. Pre-existing issue; unrelated to the changes here. Succeeded on retry.

@dmcgowan dmcgowan moved this from Needs Triage to Review In Progress in Pull Request Review Jun 13, 2026
Synchronize the gc scheduler to complete all collections before metadata
plugin is closed during server shutdown.

The scheduler's event senders (mutationCallback and the wait() trigger)
deliver to an unbuffered eventC via fire-and-forget goroutines. Once the
run loop exists on Close(), nothing will read eventC, so gate sending
events on scheduler done to prevent leaking a goroutine per metadata
mutation. Pending wait() callers using a context distinct from the run
loop's could likewise hang until their own context expired. Risk is low
since server is shutting down, but graceful teardown is desirable.
In-flight and late callers are released with errSchedulerClosed instead
of blocking.

Signed-off-by: Austin Vazquez <[email protected]>
@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.

@dmcgowan dmcgowan moved this from Review In Progress to Needs Update in Pull Request Review Nov 26, 2026
@dmcgowan dmcgowan added this to the 2.5 milestone Nov 26, 2026

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 Update

Development

Successfully merging this pull request may close these issues.

4 participants