Repository navigation
Open
Description
Description
When I was troubleshooting the problem that the Reason was not OOMKilled, I found that the container lost the TaskOOM event.
Steps to reproduce the issue
e2e: https://prow.k8s.io/view/gs/kubernetes-jenkins/logs/ci-containerd-node-e2e-1-7/1683184526936772608
logfile: https://storage.googleapis.com/kubernetes-jenkins/logs/ci-containerd-node-e2e-1-7/1683184526936772608/artifacts/tmp-node-e2e-92a26bb7-cos-97-16919-353-1-system.log
containerd_id: 98bac6c4b73cfd4c647647aa80248208b67de059874d4ddfdd1aa43ea3967e54
containerd_name: oomkill-multi-target-container
- kernel having trigger oom
Jul 23 18:56:46 tmp-node-e2e-92a26bb7-cos-97-16919-353-1 kernel: oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=cri-containerd-98bac6c4b73cfd4c647647aa80248208b67de059874d4ddfdd1aa43ea3967e54.scope,mems_allowed=0,oom_memcg=/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod17efb6ec_09ab_4eec_8ad6_f953eb1a7466.slice,task_memcg=/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod17efb6ec_09ab_4eec_8ad6_f953eb1a7466.slice/cri-containerd-98bac6c4b73cfd4c647647aa80248208b67de059874d4ddfdd1aa43ea3967e54.scope,task=dd,pid=38287,uid=0
Jul 23 18:56:46 tmp-node-e2e-92a26bb7-cos-97-16919-353-1 kernel: Memory cgroup out of memory: Killed process 38287 (dd) total-vm:21724kB, anon-rss:14744kB, file-rss:508kB, shmem-rss:0kB, UID:0 pgtables:68kB oom_score_adj:997
Jul 23 18:56:46 tmp-node-e2e-92a26bb7-cos-97-16919-353-1 kernel: Tasks in /kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod17efb6ec_09ab_4eec_8ad6_f953eb1a7466.slice/cri-containerd-98bac6c4b73cfd4c647647aa80248208b67de059874d4ddfdd1aa43ea3967e54.scope are going to be killed due to memory.oom.group set
- and then containerd exit shim
Jul 23 18:56:46 tmp-node-e2e-92a26bb7-cos-97-16919-353-1 containerd[910]: time="2023-07-23T18:56:46.329304474Z" level=debug msg="received exit event container_id:\"98bac6c4b73cfd4c647647aa80248208b67de059874d4ddfdd1aa43ea3967e54\" id:\"98bac6c4b73cfd4c647647aa80248208b67de059874d4ddfdd1aa43ea3967e54\" pid:38265 exit_status:137 exited_at:{seconds:1690138606 nanos:325950236}"
Jul 23 18:56:46 tmp-node-e2e-92a26bb7-cos-97-16919-353-1 containerd[910]: time="2023-07-23T18:56:46.389869167Z" level=info msg="shim disconnected" id=98bac6c4b73cfd4c647647aa80248208b67de059874d4ddfdd1aa43ea3967e54 namespace=k8s.io
Jul 23 18:56:46 tmp-node-e2e-92a26bb7-cos-97-16919-353-1 containerd[910]: time="2023-07-23T18:56:46.390142692Z" level=warning msg="cleaning up after shim disconnected" id=98bac6c4b73cfd4c647647aa80248208b67de059874d4ddfdd1aa43ea3967e54 namespace=k8s.io
- After that, no TaskOOM event was received until container delete.
Describe the results you received and expected
Expect to receive TaskOOM event.
What version of containerd are you using?
1.7
Any other relevant information
ubuntu
Show configuration if it is related to CRI plugin.
no
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
fuweid commentedon Jul 31, 2023
@Iceber is the issue you mentioned before? Let's say that init command is
sh -c "oom-process". The "oom-process" causes the oom event but thesh -cdoesn't. So, the containerd only records thesh -cexit code instead of sub-process's.lengrongfu commentedon Aug 1, 2023
Discuss with @Iceber and think that the shim process exits too quickly, causing the shim not to receive the OOM event.
My idea is that the current watch oom
s.ep.Addis executed after the process startscontainer.Start, whether we can put it before the start.containerd/runtime/v2/runc/task/service.go
Lines 263 to 273 in 40f2654
Iceber commentedon Aug 1, 2023
It is also possible that the cgroup was added to the oom watcher after the container was started, and this was when the process was already oom and the cgroup watcher lost the oom event
lengrongfu commentedon Aug 3, 2023
/assign
SergeyKanzhelev commentedon Aug 22, 2023
Can it be the same as this than: #8180?
lengrongfu commentedon Aug 26, 2023
looks like a problem.
lengrongfu commentedon Sep 5, 2023
find
ContainerIDvalue is notContainerID, isSandboxID.4bcba7fc4369fee4d7d2e6263b58fce52cfc928c6a31cfac4d43c838708991ceis error, but it is SandboxID.SergeyKanzhelev commentedon Sep 6, 2023
xlink with some CRI-O worka around this: kubernetes/kubernetes#120460 (comment)
tych0 commentedon Nov 21, 2023
We have also hit this, I can reproduce relatively easily via:
2 remaining items
dosubot commentedon Jun 11, 2025
Hi, @lengrongfu. I'm Dosu, and I'm helping the containerd team manage their backlog. I'm marking this issue as stale.
Issue Summary:
ContainerIDwas incorrectly set toSandboxID.Next Steps:
Thank you for your understanding and contribution!
patrickshan commentedon Dec 3, 2025
This is still happening for containerd 2.1.4 and it doesn't seem to be fixed based on the last 2.1.5 release notes.
ningmingxiao commentedon Dec 3, 2025
can you reproduce it @patrickshan
ningmingxiao commentedon Dec 3, 2025
#12614 this pr maybe can reduce the probability of it happening. @patrickshan
patrickshan commentedon Dec 3, 2025
We’ve observed this behavior occasionally in our cluster. After further investigation, we found there was an 8-minute delay between when the TaskOOM event occurred and when containerd actually received it, due to the node being under some load at the time. This appears to be a different issue from the one your PR addresses.
ningmingxiao commentedon Dec 3, 2025
you can add some log before and after s.publisher.Publish to address who use much time @patrickshan
fuweid commentedon Feb 1, 2026
Hi @lengrongfu
I will take over this task since I already made some changes to avoid this issue.
Please let me know if you're still working on this case. Thanks for the report.
/assign
dosubot commentedon Aug 8, 2026
Hi, @lengrongfu. I'm Dosu, and I'm helping the containerd team manage their backlog and am marking this issue as stale.
Issue Summary
TaskOOMevent was not emitted even though kernel logs confirmed a memcg OOM kill.TaskOOMcould be emitted with theSandboxIDinstead of theContainerIDin some cases.ctr-based repro was shared, and later confirmation showed the issue still occurs in containerd 2.1.4.Next Steps
Thanks for your understanding and contribution.
fix(sandbox): detect OOM kills reliably on Docker (#61)