Repository navigation
Description
Description
We are trying a back-to-back installation and deletion of application (50pods) and in some iterations a few pods get stuck in Terminating state forever.
The containerd logs show a StopContainer failed error when trying to stop the container and it continues forever have repeated error many times.
Jun 26 07:44:44 containerd[1891085]: time="2024-06-26T07:44:44.559390176Z" level=error msg="StopContainer for \"256a184124d5b4715ef4caf2deab0b6a25ba338aa78805b6aa2b0a055eeb159c\" failed" error="rpc error: code = DeadlineExceeded desc = an error occurs during waiting for container \"256a184124d5b4715ef4caf2deab0b6a25ba338aa78805b6aa2b0a055eeb159c\" to be killed: wait container \"256a184124d5b4715ef4caf2deab0b6a25ba338aa78805b6aa2b0a055eeb159c\": context deadline exceeded"
And another test have similar error after few days:
Jun 30 19:49:39 containerd[4166223]: time="2024-06-30T19:49:39.401009033Z" level=error msg="StopContainer for \"c08d38b62a1d1f2d80d7be8383a5bf0398c296c42b4276b936f3b84eb7fbb6fa\" failed" error="rpc error: code = Canceled desc = an error occurs during waiting for container \"c08d38b62a1d1f2d80d7be8383a5bf0398c296c42b4276b936f3b84eb7fbb6fa\" to be killed: wait container \"c08d38b62a1d1f2d80d7be8383a5bf0398c296c42b4276b936f3b84eb7fbb6fa\": context canceled"
Jun 30 19:49:39 containerd[4166223]: time="2024-06-30T19:49:39.482845511Z" level=error msg="ExecSync for \"c08d38b62a1d1f2d80d7be8383a5bf0398c296c42b4276b936f3b84eb7fbb6fa\" failed" error="failed to exec in container: failed to start exec \"20291caecb3748213b74361fbde4ed2ce93c458c76897f6107e7cc7b84234b07\": OCI runtime exec failed: exec failed: cannot exec in a stopped container: unknown"
This never auto-recovers and the only way to recover from this issue is to restart containerd.
The crictl ps, shows that the related container in the list, we tried to exec in the container and it stays
OCI runtime exec failed: exec failed: cannot exec in a stopped container: unknown has exited
So it seems that container is stopped but was not deleted from running container list.
Steps to reproduce the issue
It is difficult to reproduce. But once it reproduced, it is giving consistent error on stop container.
- Doing multiple iteration of installation and deletion on 50 pods.
- Few pods stays in terminating state and containerd was generating StopContainer failure.
Describe the results you received and expected
When waitContainerStop() is giving error during timeout, stopContainer() function should handle it by logging the error and start to return the cleanupUnknownContainer() which should eventually remove the container. So Containerd should stop and remove the container. Pod shouldn't stayed in terminating state and got deleted.
What version of containerd are you using?
containerd v1.7.15 926c958
Any other relevant information
$ runc --version
runc version 1.1.12
commit: v1.1.12-0-g51d5e946
spec: 1.0.2-dev
go: go1.17.6
libseccomp: 2.5.3
Show configuration if it is related to CRI plugin.
No response
Activity
ningmingxiao commentedon Oct 5, 2024
you can try this pr 421a4b5
introduced by 892dc54
samuelkarp commentedon Oct 7, 2024
This is most likely #10589, which is fixed in 1.7.22.
smoshiur1237 commentedon Oct 15, 2024
@ningmingxiao @samuelkarp
We have tried the fix that you have mentioned and we haven't seen the issue re-producible in our system. The solution here to use upgradedd version of containerd and containerd-shim-runc-v2 which is 1.7.22(have the fix), same time we also need to use runc- 1.1.14. Thanks for your information.
So I am closing this issue. If we see the issue again, will re-open it.
jzkinetic commentedon Nov 13, 2024
I can confirm that this issue is not resolved.
Here is a container that is stuck in "terminating" state in K8s.
./crictl exec 9292605de2272 lsoutputs:./crictl stopp 74317c53a96b7outputs:Have tried updating to latest version of containerd and runc, neither have worked.
ningmingxiao commentedon Nov 13, 2024
ctr -n k8s.io t ls |grep containerid
kill -10 1111 (shimpid) print shim stack in containerd log.
kill -10
pidof containerdprint containerd stack in /tmp/@jzkinetic
antoniotamer commentedon Feb 21, 2025
I'm seeing the same issue. Almost the same containerd version (1.7.24), same scenario as the poster.
samuelkarp commentedon Feb 21, 2025
@jzkinetic @antoniotamer Please open a new issue if you are running into a new problem.
ningmingxiao commentedon Feb 21, 2025
ctr -n k8s.io task ls show task status?