Repository navigation
cri: don't leak task when StartContainer cleanup fails to delete task - #14218
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The UNKNOWN state is not persisted, so restart recovery can still leave tasks leaked.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Updates CRI start-failure cleanup so containers with unconfirmed task deletion remain recoverable for later cleanup retries.
Changes:
- Track task deletion failures during
StartContainercleanup. - Record affected containers as
UNKNOWN. - Add test coverage and configurable test client services.
| File | Description |
|---|---|
internal/cri/server/container_stats_stream_test.go |
Extends test client configuration. |
internal/cri/server/container_start.go |
Records unknown state when task deletion fails. |
internal/cri/server/container_start_test.go |
Tests cleanup failure state transitions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Handle ErrNotFound as unconfirmed cleanup and initialize NRI in the regression test.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
Resolved since last review (1)
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Restart recovery does not handle an EXITED container with a still-running task, potentially leaving cleanup unreachable.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
When StartContainer fails after the task is created and the cleanup task delete fails (e.g. it timed out on a stuck shim), the container was still recorded as EXITED while its task remained. RemoveContainer only reaps tasks for RUNNING and UNKNOWN containers, so every kubelet GC retry failed with "cannot delete running task" and the container was never collected. Record the container as UNKNOWN when task cleanup cannot be confirmed so RemoveContainer force-stops it and retries the cleanup, keeping the StartError reason in both cases. Signed-off-by: Maksym Pavlenko <[email protected]>
|
/cherry-pick release/2.4 |
|
@mxpv: new pull request created: #14223 DetailsIn response to this:
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. |

When
StartContainerfails after the task is created and the cleanup task delete fails (e.g. it timed out on a stuck shim), the container was recorded asEXITEDwhile its task could potentially remained.RemoveContaineronly reaps tasks forRUNNINGandUNKNOWNcontainers, so every kubelet GC retry failed with "cannot delete running task" and the container was never collected.Record the container as
UNKNOWNwhen task cleanup cannot be confirmed soRemoveContainerforce-stops it and retries the cleanup.