Repository navigation
Description
Description
After a failed liveness probe, kubelet initiated container termination via StopContainer CRI call. The termination process involved multiple retry attempts, each failing with context canceled or DeadlineExceeded. Eventually, the container process was killed (SIGKILL sent at 10:39:32), the shim was removed, and the cgroup was deleted.
However, after all physical resources were cleaned up, querying the container state reveals a state inconsistency:
ctr tasks lscorrectly showsSTOPPEDcrictl inspectincorrectly showsCONTAINER_RUNNINGwithfinishedAtunset (zero time)
As a result, kubelet continues to call StopContainer in an infinite loop, receiving DeadlineExceeded errors because it's trying to stop a container that no longer exists. The pod remains stuck in Terminating state indefinitely.
The only recovery is to restart containerd.
Environment
- containerd: 1.7.27 (commit 05044ec)
- runc: 1.2.5
- Kubernetes: 1.31.2
Observed State
containerd task API shows STOPPED:
$ ctr -n k8s.io tasks ls | grep acaca462a89ac
acaca462a89acd5d959f9598c8d47ce7f72e32fc86f13827f6fbeb7e5d1cd424 4758 STOPPEDCRI API shows RUNNING:
$ crictl inspect acaca462a89ac | jq -r '.status.state, .status.finishedAt'
CONTAINER_RUNNING
0001-01-01T00:00:00ZPhysical resources are all cleaned up:
# Process does not exist
$ ls /proc/4758
ls: cannot access '/proc/4758': No such file or directory
# Shim removed
$ ps aux | grep containerd-shim | grep acaca462a89ac
(no output)
# Cgroup deleted
$ ls /sys/fs/cgroup/kubepods/burstable/pod39ea.../acaca462a89ac...
ls: cannot access: No such file or directoryTimeline
| Time | Component | Event |
|---|---|---|
| 10:36:31 | kubelet | StopContainer failed: DeadlineExceeded |
| 10:36:31 | kubelet | "Container kube-controller-manager failed liveness probe, will be restarted" |
| 10:36:31 | kubelet | "Killing container with grace period 30s" |
| 10:39:01 | kubelet | StopContainer failed: DeadlineExceeded (retry) |
| 10:39:01 | containerd | StopContainer failed: context canceled |
| 10:39:02 | containerd | StopContainer with timeout 30s |
| 10:39:32 | containerd | SIGKILL sent |
| 10:41:32 | containerd | StopContainer failed: context canceled |
| 10:41:32 | containerd | "Skipping the sending of signal terminated... because a prior stop already sent the signal" |
Logs
kubelet:
Oct 14 10:36:31 kubelet[8345]: E1014 10:36:31.256309 "StopContainer from runtime service failed" err="rpc error: code = DeadlineExceeded desc = context deadline exceeded" containerID="acaca462a89ac"
Oct 14 10:36:31 kubelet[8345]: I1014 10:36:31.605638 "Message for Container of pod" containerMessage="Container kube-controller-manager failed liveness probe, will be restarted"
Oct 14 10:36:31 kubelet[8345]: I1014 10:36:31.605725 "Killing container with a grace period" containerName="kube-controller-manager" gracePeriod=30
Oct 14 10:39:01 kubelet[8345]: E1014 10:39:01.613275 "StopContainer from runtime service failed" err="rpc error: code = DeadlineExceeded desc = context deadline exceeded" containerID="acaca462a89ac"
Oct 14 10:39:02 kubelet[8345]: I1014 10:39:02.176566 "Message for Container of pod" containerMessage="Container kube-controller-manager failed liveness probe, will be restarted"
Oct 14 10:39:02 kubelet[8345]: I1014 10:39:02.176763 "Killing container with a grace period" containerName="kube-controller-manager" gracePeriod=30
containerd:
Oct 14 10:39:01 containerd[7758]: level=error msg="StopContainer for \"acaca462a89ac\" failed" error="rpc error: code = Canceled desc = an error occurs during waiting for container to be killed: context canceled"
Oct 14 10:39:02 containerd[7758]: level=info msg="StopContainer for \"acaca462a89ac\" with timeout 30 (s)"
Oct 14 10:39:32 containerd[7758]: level=info msg="Kill container \"acaca462a89ac\""
Oct 14 10:41:32 containerd[7758]: level=error msg="StopContainer for \"acaca462a89ac\" failed" error="rpc error: code = Canceled desc = an error occurs during waiting for container to be killed: context canceled"
Oct 14 10:41:32 containerd[7758]: level=info msg="StopContainer for \"acaca462a89ac\" with timeout 30 (s)"
Oct 14 10:41:32 containerd[7758]: level=info msg="Skipping the sending of signal terminated to container \"acaca462a89ac\" because a prior stop with timeout>0 request already sent the signal"
Related Issues
- Pod stays in terminating state and waiting for container to be stopped by containerd #10755 — Pod stays in terminating state (same symptoms, closed)
- Containerd fails to stop containers #6080 — Containerd fails to stop containers, "Failed to handle container TaskExit event"
Expected Behavior
CRI plugin should update container status to EXITED when the container process terminates, regardless of whether the initiating gRPC context was cancelled.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
ningmingxiao commentedon Dec 12, 2025
cat you kill -10
pidof containerdto print stack at /tmp/ @evgfitilningmingxiao commentedon Dec 12, 2025
can you see "received exit event" log and show log about acaca462a8 @evgfitil
evgfitil commentedon Dec 22, 2025
@ningmingxiao thank you for the guidance. The issue reproduced again on a different cluster. This bug is flaky - it depends on specific timing of context cancellations during overlapping StopContainer calls, which makes it hard to catch in the act
Answers to your questions
New reproduction details
Container ID:
efd00be6ff246a778fe2c045916f51e3bef3fc6e8a1443b57292e9e7a8a69457kubelet logs:
containerd logs:
state inconsistency:
ningmingxiao commentedon Dec 23, 2025
can you show container efd00be6ff246 process tree ( should include shim process )? @evgfitil
evgfitil commentedon Dec 23, 2025
Perhaps I misunderstood the question, but the shim process and container process no longer exist
ningmingxiao commentedon Dec 23, 2025
cat containerd.log | grep efd00be6ff2|grep -i sandbox you can find sandbox id then ps -auxf show the tree that include sandboxid @evgfitil
ningmingxiao commentedon Dec 24, 2025
can you show the error detail (the error is omitted) and containerd start time @evgfitil
evgfitil commentedon Dec 24, 2025
ningmingxiao commentedon Dec 24, 2025
can you show pid 3045 child process status ? (use ps -auxf )and systemctl status containerd @evgfitil
evgfitil commentedon Dec 24, 2025
https://gist.github.com/evgfitil/6c4186c79fbf33fbb7e5dd613ad386ca
ningmingxiao commentedon Dec 24, 2025
you don't need grep I want to see it's child process @evgfitil
28 remaining items
runc-shim: decouple stdio drain budget from CRI event-handler context
runc-shim: decouple stdio drain budget from CRI event-handler context
runc-shim: decouple stdio drain budget from CRI event-handler context
fix(shim): prevent exit event loss from SIGCHLD coalescing
fix(shim): prevent exit event loss from SIGCHLD coalescing
fix(shim): prevent exit event loss from SIGCHLD coalescing
fix(shim): prevent exit event loss from SIGCHLD coalescing
fix(shim): prevent exit event loss from SIGCHLD coalescing
dosubot commentedon Aug 15, 2026
Hi, @evgfitil. I'm Dosu, and I'm helping the containerd team manage their backlog and am marking this issue as stale.
Issue Summary
StopContainercalls can leave CRI metadata stuck atCONTAINER_RUNNINGwith nofinishedAt.pkg/process.(*Init).Wait.StopContainercancellations and noreceived exit event/TaskExitentries, which suggests the exit notification path is being missed.Next Steps
Thanks for your understanding and contribution.
github-actions commentedon Aug 30, 2026
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.
sgohl commentedon Aug 31, 2026
Sorry for the AI slop, but I barely grasp the actual problem myself and required help to formulate a follow-up
I believe this issue should be reopened.
We are seeing the same CRI/containerd state inconsistency on a current K3s/Kubernetes stack under heavy short-lived CronJob workload.
Environment:
v1.36.3+k3s1v2.3.2-k3s2v1io.containerd.runc.v2The main symptom is that completed containers remain reported as
Runningby Kubernetes and CRI for several minutes, even though the underlying containerd task has already stopped.Example:
For the same container:
However, containerd already reports the task as stopped:
So the state is:
This is essentially the same inconsistency described in #12678: the process/task has exited, but the CRI state is not updated to
CONTAINER_EXITED, leavingfinishedAtunset and causing kubelet to continue treating the container as running.We also see related sandbox cleanup failures:
These occur repeatedly for old CronJob sandboxes.
A directly executed CRI call reproduced the same problem:
The call failed after approximately two seconds.
For affected sandboxes we observed another state inconsistency:
The corresponding
containerd-shim-runc-v2process was still present while the task itself was already:There are also kubelet/cAdvisor errors related to disappearing or inconsistent container/cgroup state:
and:
This is reproducible across multiple worker nodes and affects a large number of short-lived CronJob containers.
We initially suspected Kubernetes
ImageVolume, SMB/NFS teardown, or CNI cleanup. However:ImageVolumeon one worker did not resolve the main issue.ctr STOPPED/CRI RUNNINGinconsistency.The important point is that this is not just a stale pod status in Kubernetes. The inconsistency exists directly inside containerd:
The original issue was reported against containerd 1.7.x. We can reproduce the same fundamental failure on containerd
2.3.2-k3s2.For that reason, I believe #12678 is still relevant and should be reopened, or alternatively linked to an active issue tracking the same CRI TaskExit/state propagation problem in containerd 2.x.
ningmingxiao commentedon Aug 31, 2026
can you show containerd stack use kill -10
pidof containerdwill print containerd stack at /tmp/ dir and show containerd log about 41133fb5 @sgohl