CRI: stop signal dropped when StopContainer follows StartContainer, container runs until timeout
I maintainer di solito rispondono entro 1 giorno
@Dineshjnld ci sta già lavorando.
Dal 29/11/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- infrastructure
Direzione di ricerca
Start with internal/cri/server/container_stop.go and the linked Linux kernel/signal.c behavior, then inspect libcontainer/standard_init_linux.go to understand the start/exec race. Reproduce with the provided crictl commands and the Python PID-namespace container, observing /proc/<pid>/status for SigCgt and SigBlk. The fix is complete when StopContainer retries the stop signal during its timeout while init neither catches nor blocks it, and the reproducer exits promptly instead of waiting for SIGKILL.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
If StopContainer arrives right after StartContainer returns, the stop signal can reach the container's PID 1 before the process has installed its handler. The kernel discards a default-action signal sent to a PID namespace init (signal.c), and containerd sends the stop signal only once (container_stop.go), so the container keeps running until the SIGKILL at the end of the timeout.
runc start returns before init execs the user process (standard_init_linux.go), and after exec the program still has to get to its handler setup. The kubelet lands in this window whenever a pod is deleted while it is starting (e.g. during the image pull): it calls StopContainer ~1.5 ms after StartContainer returns and then waits the full terminationGracePeriodSeconds. We noticed it when a CloudNativePG pod deleted during startup ignored SIGTERM and held up a node drain for its 1800s grace period.
Steps to reproduce the issue
Python whose first statement installs a SIGTERM handler. "pid":1 gives the container its own PID namespace, as the kubelet does. Drop cgroup_parent if containerd uses cgroupfs.
cat > pod.json <<'J'
{"metadata":{"name":"sigtest","namespace":"default","uid":"sigtest"},"linux":{"cgroup_parent":"system.slice"}}
J
cat > ctr.json <<'J'
{"metadata":{"name":"app"},"image":{"image":"docker.io/library/python:3.14-slim"},
"command":["python3","-c","import signal,sys,time\nsignal.signal(signal.SIGTERM, lambda *a: sys.exit(0))\ntime.sleep(3600)"],
"linux":{"security_context":{"namespace_options":{"pid":1}}}}
J
crictl pull docker.io/library/python:3.14-slim >/dev/null
POD=$(crictl runp pod.json); CTR=$(crictl create $POD ctr.json pod.json)
crictl start $CTR; time crictl stop -t 30 $CTR
crictl inspect -o go-template --template '{{.status.exitCode}}' $CTR
Describe the results you received and expected
crictl stop -t 30 takes 30s and the exit code is 137, in 20 of 20 runs. The signal/signal_generate tracepoint shows the SIGTERM hitting python3 (already exec'd) with res=1 (ignored). With sleep 1 between start and stop, or with a second SIGTERM sent from the host, it exits 0 right away. Through the kubelet (v1.37.0 in kind), deleting the pod during its image pull takes the full grace period.
Expected: the container gets the stop signal and exits within milliseconds.
What version of containerd are you using?
containerd v2.3.7 (also v2.3.4 and main at 0e1fb1bf)
Any other relevant information
runc 1.4.3, kernel 7.2.12 arm64, Debian 13 (kind node). Not specific to Python: a static Go binary whose main starts with signal.Notify lost it in 5 of 30 runs under a 100m CPU limit, with StopContainer sent right after StartContainer.
Suggested fix: keep re-sending the stop signal during the timeout while the init process neither catches nor blocks it (SigCgt/SigBlk in /proc/<pid>/status), instead of sending it exactly once.
- Lingua principale
- Go
- Stelle
- 21.6k
- Fork
- 4.2k
- Merge medio
- 2g 9h
- PR unite (30g)
- 86
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di containerd/containerd
-
CRI attach: wiring stdin before stdout drops initial outputForse già presa @YiD11 l’ha presa 36 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
containerd/containerd#14476 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
should it be `size-offset` in line 301 (`core/content/helpers.go`, `seekReader()`)Forse già presa @AdamMagued l’ha presa 34 giorni fa. Apertakind/bug status/more-info-needed
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
containerd/containerd#14278 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
CRI: PullImage hangs forever when image_pull_progress_timeout = "0s" (default transfer service path)Forse già presa @refleeexzz l’ha presa 79 giorni fa. Apertakind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
containerd/containerd#14158 · 8 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
docs: 'allows to split' grammar in containerd-config.toml man pageForse già presa @mrchatam l’ha presa 81 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
containerd/containerd#14154 ·
I maintainer di solito rispondono entro 1 giorno
-
`RemoveVolatileOption` cannot recognize mount type "fuse.nydus-overlayfs" from nydus-snapshotterForse di nuovo libera @ekalinin l’ha presa 109 giorni fa e non c’è nessuna pull request aperta. Apertaarea/snapshotters kind/feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
containerd/containerd#13573 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di containerd/containerd
Issue simili
-
P3 tech debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
kind/feature needs-triage priority/unprioritized
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
NVIDIA/k8s-test-infra#1504 ·
I maintainer di solito rispondono entro 1 giorno
-
Area/Infrastructure Aspect/Infra Resources Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
wso2/agent-manager#2717 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
open-policy-agent/opa#9685 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno