fix(minimal in vm): raise rlimit to sane default - #1085
Conversation
📝 WalkthroughWalkthroughMicroVM startup now configures and raises ChangesMicroVM open-file limit handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/minimald/src/main.rs`:
- Around line 484-503: Add or update the booted-VM integration test covering
listen_args.rlimit_nofile and guest::raise_nofile_limit so it boots a guest with
a configured RLIMIT_NOFILE and verifies PID 1 observes that inherited limit
before daemon or session startup. Retain the existing in-process setrlimit unit
coverage, but ensure the VM test validates inheritance across the fork/exec boot
boundary.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d654eea7-139d-4f0c-804d-91233d304162
📒 Files selected for processing (2)
crates/minimald/src/guest.rscrates/minimald/src/main.rs
| // Before anything forks from us and inherits the limits. Best effort: the | ||
| // kernel default is the prior behaviour, not a reason to refuse to boot. | ||
| if let Some(limit) = listen_args.rlimit_nofile { | ||
| match guest::raise_nofile_limit(limit) { | ||
| Ok(effective) if effective >= limit => { | ||
| tracing::debug!(nofile = effective, "raised the open-file limit"); | ||
| } | ||
| Ok(effective) => tracing::warn!( | ||
| requested = limit, | ||
| effective, | ||
| "the open-file limit could not be raised as far as requested; fd-hungry builds \ | ||
| may fail with EMFILE" | ||
| ), | ||
| Err(e) => tracing::warn!( | ||
| error = %e, | ||
| requested = limit, | ||
| "could not raise the open-file limit; fd-hungry builds may fail with EMFILE" | ||
| ), | ||
| } | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== file list =="
git ls-files | rg '(^|/)(main\.rs|.*test.*|.*e2e.*|.*integration.*|justfile|JUSTFILE|Makefile|rust-toolchain\.toml|docs/.*rust-coding-standards\.md)$' || true
echo
echo "== search for rlimit / nofile =="
rg -n "rlimit_nofile|raise_nofile_limit|setrlimit|nofile|RLIMIT_NOFILE" crates docs .github justfile Makefile -S || true
echo
echo "== inspect minimald main around relevant lines =="
sed -n '430,540p' crates/minimald/src/main.rs
echo
echo "== search for integration tests around VM boot =="
rg -n "booted VM|boot.*VM|e2e|test-vm|integration test|daemon/session|session startup|PID 1" crates tests . -S || trueRepository: gominimal/minimal
Length of output: 50373
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '== helper references ==\n'
rg -n "raise_nofile_limit|rlimit_nofile" crates/minimald -S || true
printf '\n== likely test files ==\n'
fd -a -t f '.*(test|tests|e2e|integration).*' crates/minimald . || true
printf '\n== likely mentions of nofile in tests ==\n'
rg -n "nofile|NOFILE|EMFILE|RLIMIT_NOFILE" crates/minimald/tests crates/minimald/src crates/minimald -g '!target' -S || trueRepository: gominimal/minimal
Length of output: 6907
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== ast-grep outline: relevant test files =="
for f in crates/minvmd/tests/boot_integration.rs crates/minvmd/tests/resource_vm_integration.rs crates/minimald/src/guest.rs; do
echo "--- $f ---"
ast-grep outline "$f" --view expanded || true
done
echo
echo "== RLIMIT_NOFILE in test files =="
rg -n "RLIMIT_NOFILE|nofile|raise_nofile_limit|getrlimit|setrlimit|DEFAULT_MICROVM_NOFILE_LIMIT" \
crates/minvmd/tests crates/minimald/src/guest.rs -S || true
echo
echo "== read boot_integration.rs slice =="
sed -n '1,220p' crates/minvmd/tests/boot_integration.rs
echo
echo "== read resource_vm_integration.rs slice =="
sed -n '1,260p' crates/minvmd/tests/resource_vm_integration.rs
echo
echo "== read guest.rs unit-test slice =="
sed -n '1320,1375p' crates/minimald/src/guest.rsRepository: gominimal/minimal
Length of output: 17024
Add VM-backed coverage for RLIMIT_NOFILE. The current unit test only exercises setrlimit in-process; it doesn’t prove the guest PID 1 starts with the configured inherited limit before daemon/session startup. Add or update a booted-VM integration test that asserts the guest inherits the limit.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/minimald/src/main.rs` around lines 484 - 503, Add or update the
booted-VM integration test covering listen_args.rlimit_nofile and
guest::raise_nofile_limit so it boots a guest with a configured RLIMIT_NOFILE
and verifies PID 1 observes that inherited limit before daemon or session
startup. Retain the existing in-process setrlimit unit coverage, but ensure the
VM test validates inheritance across the fork/exec boot boundary.
Source: Coding guidelines
Summary by CodeRabbit
New Features
Bug Fixes
Note
Raise RLIMIT_NOFILE to 65536 in minimald microVM init processes
raise_nofile_limitin guest.rs that sets both soft and hardRLIMIT_NOFILEto a requested value, falling back to the current hard limit if the request exceedsfs.nr_open.DEFAULT_MICROVM_NOFILE_LIMITconstant (65536) used automatically whenminimaldruns as microVM init.--rlimit-nofileCLI flag in main.rs to override the limit; the effective soft limit and any failures are logged.RLIMIT_NOFILEof 65536 instead of the system default.Macroscope summarized 93e97d3.