runc-shim: soft RLIMIT_NOFILE stays at the inherited value (e.g. 1024), unlike the Go shim
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 43/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- linux, rust
調査の方向性
Start by reading the Rust shim entry point in crates/runc-shim/src/main.rs and compare its startup path with the Go shim’s RLIMIT_NOFILE behavior described in the issue. Check how the project handles Linux resource limits and whether the change belongs in the runc shim or shared crates/shim bootstrap. Done means the Rust shim can handle the reported per-pod file descriptor load and the project’s maintainers have answered whether this limit should be raised in the shim.
索引モデルが issue の本文から書いたものです。
説明
Problem
With the Rust runc shim (io.containerd.runc.v2-rs / containerd-shim-runc-v2-rs), the shim process's soft RLIMIT_NOFILE remains at whatever it inherited from containerd (typically 1024 on hosts using the default systemd limits), whereas the Go shim (containerd-shim-runc-v2) ends up with soft ≈ hard (e.g. 524287).
Because the runc v2 shim is pod-level — every container in a pod is served by a single shim process — the shim accumulates per-container file descriptors (stdio FIFOs, log pipes, etc.). With soft=1024 a single pod tops out at roughly ~140 containers, after which starting a new task fails with:
failed to create shim task: ... Too many open files (os error 24)
This is easy to hit on containerd 1.8+/2.x, where the reference containerd.service no longer sets LimitNOFILE (containerd/containerd#8924), so the effective soft limit falls back to systemd's DefaultLimitNOFILE=1024:524288.
Root cause
The Go shim is fine because of the Go runtime, not containerd-specific code:
src/syscall/rlimit.go'sinit()raises the process's own soft NOFILE tohard-1.src/syscall/exec_linux.gorestores child processes to the original (pre-raise) limit, so shims start at the inherited 1024 — but the Go shim then re-raises itself via the same init.
The Rust shim has no equivalent: neither crates/shim nor crates/runc-shim calls setrlimit/prlimit, and there is no rlimit dependency. So the Rust shim stays at the inherited 1024.
Measured on the same host, same containerd (2.2.1), same spawn path, only the binary differs:
| process | soft | hard |
|---|---|---|
| containerd (Go) | 524287 | 524288 |
containerd-shim-runc-v2 (Go) |
524287 | 524288 |
containerd-shim-runc-v2-rs (Rust) |
1024 | 524288 |
A "fake" shim that just prints its own /proc/self/limits confirms containerd hands the child soft=1024 (Go's exec restores the original rlimit), which the Go shim then re-raises and the Rust shim does not.
Question
Should the Rust shim raise its own soft RLIMIT_NOFILE to the hard limit, mirroring what the Go runtime does for the Go shim? Or is the intended guidance to always configure LimitNOFILE / DefaultLimitNOFILE at the systemd level and leave the shim alone?
I'm happy to send a PR if the maintainers think this belongs in the shim. Two candidate locations:
crates/shimbootstrap — affects every shim built on the framework, and is the closest analog to the Go runtime behavior.crates/runc-shim/src/main.rs— runc-shim only.
Minimal change (option 2):
#[tokio::main]
async fn main() {
// Raise soft RLIMIT_NOFILE to the hard limit, mirroring the Go runtime so the
// pod-level shim can hold per-container FIFO/log fds for many containers.
#[cfg(target_os = "linux")]
unsafe {
let mut rl = libc::rlimit { rlim_cur: 0, rlim_max: 0 };
if libc::getrlimit(libc::RLIMIT_NOFILE, &mut rl) == 0 {
rl.rlim_cur = rl.rlim_max;
let _ = libc::setrlimit(libc::RLIMIT_NOFILE, &rl);
}
}
parse_version();
run::<Service>("io.containerd.runc.v2-rs", None).await;
}
Happy to adjust to the project's preferred location / style.
- 主要言語
- Rust
- スター
- 245
- フォーク
- 97
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 8
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
containerd/rust-extensions のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
containerd/rust-extensions#518 ·
メンテナーはふだん 1 日以内に返信
containerd/rust-extensions の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
area: plugins bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
clipy-recorder/clipy#1039 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
valkey-io/valkey-glide#7975 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
gofractally/psibase#2379 ·
メンテナーはふだん 3 日以内に返信
-
Qwen stream parser: a chunk with "error": null is treated as a stream error対応中かも @Beehtrix が今日担当しました。 オープンarea:models bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
brekkylab/ailoy#681 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信