CRI: stop signal dropped when StopContainer follows StartContainer, container runs until timeout
メンテナーはふだん 1 日以内に返信
@Dineshjnld がすでに取り組んでいます。
2026年11月29日 から。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 65/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Go
- スター
- 21.6k
- フォーク
- 4.2k
- 平均マージ
- 2日 9時間
- マージ済み PR(30日)
- 86
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
containerd/containerd のほかの issue
-
CRI attach: wiring stdin before stdout drops initial output対応中かも @YiD11 が 36 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
containerd/containerd#14476 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
should it be `size-offset` in line 301 (`core/content/helpers.go`, `seekReader()`)対応中かも @AdamMagued が 34 日前に担当しました。 オープンkind/bug status/more-info-needed
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
containerd/containerd#14278 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
CRI: PullImage hangs forever when image_pull_progress_timeout = "0s" (default transfer service path)対応中かも @refleeexzz が 79 日前に担当しました。 オープンkind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
containerd/containerd#14158 · コメント 8 件 ·
メンテナーはふだん 1 日以内に返信
-
docs: 'allows to split' grammar in containerd-config.toml man page対応中かも @mrchatam が 81 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
containerd/containerd#14154 ·
メンテナーはふだん 1 日以内に返信
-
`RemoveVolatileOption` cannot recognize mount type "fuse.nydus-overlayfs" from nydus-snapshotter再び着手できるかも @ekalinin が 109 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンarea/snapshotters kind/feature
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
containerd/containerd#13573 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
containerd/containerd の issue をすべて見る
似ている issue
-
P3 tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
kind/feature needs-triage priority/unprioritized
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
NVIDIA/k8s-test-infra#1504 ·
メンテナーはふだん 1 日以内に返信
-
Area/Infrastructure Aspect/Infra Resources Type/Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
wso2/agent-manager#2717 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
open-policy-agent/opa#9685 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信