Skip to content

shim_load: Consider shim leaked only if we can't find pids - #13790

Merged
mxpv merged 1 commit into
containerd:mainfrom
halaney:ahalaney/shim-leak-error
Jul 22, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
halaney:ahalaney/shim-leak-error

Conversation

@halaney

@halaney halaney commented Jul 13, 2026 •

Copy link
Copy Markdown

Right now the statement is treating any error from the shim as leaking
(len(pInfo == 0 is true for any error). It seems the intent was to only
treat shims this way if the error was not found, or if there's
legitimately no pids associated with the shim. Let's fix that up to
avoid orphaning shims that just had a small error in reading pids.

Link: #13784
Signed-off-by: Andrew Halaney [email protected]

Avoid orphaning shims on transient errors when loading process IDs

Copilot AI review requested due to automatic review settings July 13, 2026 23:10
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Jul 13, 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

Adjusts shim recovery logic in core/runtime/v2 to avoid incorrectly classifying healthy shims as “leaked” during containerd restart when PID discovery fails for transient/non-NotFound reasons (as described in #13784).

Changes:

  • Tightens the leaked-shim cleanup condition to only trigger when PID lookup succeeds but returns zero PIDs, or when PID lookup returns ErrNotFound.
  • Adds additional logging to distinguish between “cleaning leaked shim” vs “keeping shim” when PID lookup errors are ambiguous.

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

Comment thread core/runtime/v2/shim_load.go Resolved
@halaney

halaney commented Jul 14, 2026

Copy link
Copy Markdown
Author

I lumped in #13789 here as well, I figured that change was not controversial at all so I'd PR it separate, and if folks like this change as well we can either just take this PR, or I can rebase after we hash out things here and the other is merged.

@mxpv mxpv moved this from Needs Triage to Needs Reviewers in Pull Request Review Jul 14, 2026
@mxpv mxpv added the cherry-pick/2.3.x Change to be cherry picked to release/2.3 label Jul 14, 2026

@chrishenzie chrishenzie left a comment

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.

Please squash these two commits into one. The logging and recovery behavior are logically related here

Comment thread core/runtime/v2/shim_load.go Resolved
Comment thread core/runtime/v2/shim_load.go Resolved
Comment thread core/runtime/v2/shim_load.go Resolved
@github-project-automation github-project-automation Bot moved this from Needs Reviewers to Needs Update in Pull Request Review Jul 17, 2026
Copilot AI review requested due to automatic review settings July 20, 2026 14:55
@halaney
halaney force-pushed the ahalaney/shim-leak-error branch from f2c2879 to 6adda07 Compare July 20, 2026 14:55
@kubernetes-prow kubernetes-prow Bot added size/S and removed size/XS labels Jul 20, 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

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

Comment thread core/runtime/v2/shim_load.go Resolved
Comment thread core/runtime/v2/shim_load.go Resolved
Copilot AI review requested due to automatic review settings July 20, 2026 15:03
@halaney
halaney force-pushed the ahalaney/shim-leak-error branch from 6adda07 to 59323f4 Compare July 20, 2026 15:03

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 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread core/runtime/v2/shim_load.go Resolved
Copilot AI review requested due to automatic review settings July 20, 2026 15:16
@halaney
halaney force-pushed the ahalaney/shim-leak-error branch from 59323f4 to f12135d Compare July 20, 2026 15:16
@kubernetes-prow kubernetes-prow Bot added size/L and removed size/S labels Jul 20, 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

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

Comments suppressed due to low confidence (1)

core/runtime/v2/shim_load.go:210

  • The new comment above shouldCleanupShim has a couple of typos/grammar issues ("reapable"/"reap it" phrasing and missing punctuation). Since this is describing subtle cleanup criteria, it’s worth making it unambiguous.
// shouldCleanupShim determines whether or not a shim is in such a state that
// we should reap it. To be reapable we confirm that it is not a sandbox shim
// and it has no pids running

Comment thread core/runtime/v2/shim_load.go Resolved
Comment thread core/runtime/v2/shim_load.go Resolved
Right now the statement is treating any error from the shim as leaking
(len(pInfo == 0 is true for any error). It seems the intent was to only
treat shims this way if the error was not found, or if there's
legitimately no pids associated with the shim. Let's fix that up to
avoid orphaning shims that just had a small error in reading pids.

Link: containerd#13784
Signed-off-by: Andrew Halaney <[email protected]>
Copilot AI review requested due to automatic review settings July 20, 2026 18:38
@halaney
halaney force-pushed the ahalaney/shim-leak-error branch from f12135d to 54a5a60 Compare July 20, 2026 18:38
@halaney
halaney requested a review from chrishenzie July 20, 2026 18:39

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 no new comments.

@fuweid

fuweid commented Jul 22, 2026

Copy link
Copy Markdown
Member

request @chrishenzie for review here. the log change looks good to me.

Comment thread core/runtime/v2/shim_load.go Resolved
@github-project-automation github-project-automation Bot moved this from Needs Update to Review In Progress in Pull Request Review Jul 22, 2026
@mxpv
mxpv added this pull request to the merge queue Jul 22, 2026
Merged via the queue into containerd:main with commit 4c9842f Jul 22, 2026
89 of 90 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Jul 22, 2026
@mxpv

mxpv commented Jul 24, 2026

Copy link
Copy Markdown
Member

/cherry-pick release/2.3

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@mxpv: new pull request could not be created: failed to create pull request against containerd/containerd#release/2.3 from head k8s-infra-cherrypick-robot:cherry-pick-13790-to-release/2.3: status code 500 not one of [201], body:

Details

In response to this:

/cherry-pick release/2.3

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.

@chrishenzie

Copy link
Copy Markdown
Member

/cherry-pick release/2.3

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@chrishenzie: new pull request created: #13857

Details

In response to this:

/cherry-pick release/2.3

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.

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

Labels

area/runtime Runtime cherry-pick/2.3.x Change to be cherry picked to release/2.3 size/L

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants