Skip to content

Shim leak and stale container state if containerd restarts during a StopContainer operation #12600

Closed as not planned

Description

@bansodek-prog

Description

When the containerd service is restarted while a StopContainer operation is in progress, containerd can lose track of the container's shim. This results in the container's state not being updated, even after the container process has exited. Kubelet continues to see the container as running (via CRI) and gets stuck in a loop trying to terminate a process that no longer exists, causing the pod to be stuck in the Terminating state.

Steps to reproduce the issue

No response

Describe the results you received and expected

Expected behavior

containerd should gracefully handle the restart and correctly reflect the container's final state (i.e., Exited) after the restart, even if the stop operation was interrupted. The shim should be cleaned up.

Actual Behavior

The StopContainer call in the original containerd instance fails with context canceled due to the shutdown.
After restart, containerd does not have the correct state for the container. crictl ps -a may show the container still as Running.
The container process does exit, but this event seems to be missed or not reconciled by the restarted containerd instance.
Kubelet receives DeadlineExceeded errors when trying to kill the container, as it's querying containerd which reports a stale state.
Critically, log messages like "shim disconnected" or "cleaning up after shim disconnected" are missing for the affected container ID after the restart, suggesting an orphaned shim

What version of containerd are you using?

v1.7.27

Any other relevant information

No response

Show configuration if it is related to CRI plugin.

No response

Activity

  1. ningmingxiao commented on Dec 1, 2025

    @ningmingxiao
    Contributor

    can you show containerd log and containerd stack (kill -10 pidof containerd will generate stack at /tmp/)@bansodek-prog
    as far as I know containerd will recheck the container status, when restart containerd.

  2. ningmingxiao commented on Dec 1, 2025

    @ningmingxiao
    Contributor

    //assign

  3. ningmingxiao commented on Dec 1, 2025

    @ningmingxiao
    Contributor

    may be you need this pr #11634 @bansodek-prog

  4. dosubot commented on Jul 28, 2026

    @dosubot

    Hi, @bansodek-prog. I'm Dosu, and I'm helping the containerd team manage their backlog and am marking this issue as stale.

    Issue Summary

    • You reported that on containerd v1.7.27, a container can get stuck in Terminating if containerd restarts during StopContainer.
    • The reported behavior suggests containerd may lose track of the shim after restart, fail to reconcile the final state, and continue reporting the container as Running even after the process has exited.
    • In the discussion, @ningmingxiao requested containerd logs and a stack dump to confirm the restart/reconciliation path, and suggested containerd should recheck container status after restart.
    • A possible fix was also referenced in containerd PR [release/1.7] cri:fix lost container exit events if they arrive before info is cached #11634, which may address the stale state issue.

    Next Steps

    • Please let us know if this issue is still relevant on the latest version of containerd; if it is, you can keep the discussion open by commenting here.
    • Otherwise, this issue will be automatically closed in 7 days.

    Thanks for your understanding and contribution.

  5. github-actions commented on Aug 12, 2026

    @github-actions

    This issue was closed because it has been stale for 2 weeks with no activity. Feel free to reopen or create a new issue if you would like to continue working on it.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions