Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prevents daemon-wide stalls caused by unresponsive content-store backends during metadata content garbage collection. It does so by bounding backend Delete and Abort calls (which currently run while holding the content store write lock and with cancellation stripped upstream) using configurable pkg/timeout keys, so a wedged proxy plugin can no longer block all content operations indefinitely.
Changes:
- Add per-call GC timeouts for content backend
DeleteandAbort(io.containerd.timeout.gc.content.delete/.abort, default30m) viapkg/timeout. - Apply those timeouts inside
contentStore.garbageCollectwhen deleting orphaned blobs and aborting orphaned ingests. - Add synctest-backed unit tests to validate that GC abandons the pass after the first hung backend call and leaves remaining orphans for the next pass; document the new timeout keys in the config manpage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| docs/man/containerd-config.toml.5.md | Documents new timeouts keys for content GC abort/delete. |
| core/metadata/content.go | Wraps GC Delete/Abort calls with timeout.WithContext and registers default durations. |
| core/metadata/content_test.go | Adds tests ensuring hung backend calls time out and GC abandons the pass after the first timeout. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
bd9ff4c to
7e2e4ee
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
core/metadata/content.go:962
- Even with per-
Aborttimeouts, the surroundingWalkStatusRefs/ListStatusesphase is still invoked undercs.l.Lock()with the originalctxand no deadline. If a proxy backend hangs inWalkStatusRefsorListStatuses, GC can still hold the write lock indefinitely before it ever reaches the boundedAbortcalls. Consider applying timeouts to those calls too (separate keys or a shared GC-content-status key).
err = w.WalkStatusRefs(ctx, func(ref string) error {
if _, ok := ingestSeen[ref]; !ok {
abortCtx, cancel := timeout.WithContext(ctx, gcContentAbortTimeoutKey)
err := cs.Store.Abort(abortCtx, ref)
cancel()
| err = cs.Store.Walk(ctx, func(info content.Info) error { | ||
| if _, ok := contentSeen[info.Digest.String()]; !ok { | ||
| if err := cs.Store.Delete(ctx, info.Digest); err != nil { | ||
| deleteCtx, cancel := timeout.WithContext(ctx, gcContentDeleteTimeoutKey) | ||
| err := cs.Store.Delete(deleteCtx, info.Digest) | ||
| cancel() |
The content garbage collector holds the content store write lock while calling the backend Store.Walk, Store.Delete and Store.Abort. cleanupContent also detaches cancellation (context.WithoutCancel), so a backend call that never returns - e.g. a proxy content store whose RPC connection has wedged - holds the write lock forever. Every subsequent content operation then blocks behind the lock, including pull ingest, until the plugin recovers on its own. This is the content-side twin of the snapshot GC pass bounded by containerd#14026. Follow the design agreed there (a single timeout for the whole pass instead of per-call keys): io.containerd.timeout.gc.content (default 30m, operator-tunable through config.toml like the other timeout keys) is created at the top of garbageCollect and covers the Walk/Delete sweep and the ingest Abort sweep under one deadline. On timeout the pass fails, and the blobs and ingests left behind stay orphaned for the next pass. Signed-off-by: chansuke <[email protected]>
7e2e4ee to
949a994
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The current timeout wiring can cancel GC immediately when configured to 0 and should avoid doing additional work under the lock once the timeout is already exceeded.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
| gcCtx, cancel := timeout.WithContext(ctx, gcContentTimeoutKey) | ||
| defer cancel() | ||
|
|
||
| cs.l.Lock() | ||
| t1 := time.Now() |
| // gcContentTimeoutKey bounds one full content garbage collection pass: the | ||
| // backend Walk/Delete sweep and the ingest Abort sweep, all under the content | ||
| // store write lock. The deadline starts before lock acquisition; the wait | ||
| // itself is not interruptible, but its duration counts against the budget of | ||
| // the pass. An unresponsive content store (e.g. a hung proxy plugin RPC) |
|
Heads up: #14187 puts the timeout in the proxy client as an optional default_timeout, following @fuweid's suggestion in #14026. It covers the snapshot proxy only, so the content side still needs its own key because Writer outlives the call that created it. Leaving it to the maintainers whether that replaces the per-component approach here. |
Uh oh!
There was an error while loading. Please reload this page.