Repository navigation
start/up/restart: validate --cpus/--memory/--disk before booting; down --vm no-ops when idle - #128
Closed
Jonesc2321601 wants to merge 10 commits into
Closed
Jonesc2321601 wants to merge 10 commits into
Jonesc2321601 wants to merge 10 commits into
Conversation
Member
|
Thanks for working on #110, @Jonesc2321601! Closing this PR in favor of #122, which has now been merged. A few technical notes from our review:
Appreciate your thorough testing notes! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
hanzo start,hanzo restart, andhanzo upaccept--cpus,--memory,--diskstraight into the microVM boot path. A shape that cannot boot does not fail there:
the VM starts, then the guest dies of an OOM kill or a full root filesystem, which
surfaces as an opaque runtime crash far from the flag that caused it.
This PR checks the shape on the host, before anything boots, and names the flag and
a value that works. It also makes
hanzo down --vmon an idle machine a no-opinstead of whatever the stop path reports for a missing pid.
--cpus 0/--cpus 1--cpus 999--memory 1024--memory 4GiB--disk 1024--disk 32GiB--cpus 16on an 8-CPU host--cloud-onlyhanzo down --vmwhen idle路 no local runtime is running 鈥?nothing to stopHow it is built
src/commands/lifecycle/shape.rsis new and pure:validate()(bounds),validate_host()(host capacity, skipped when the probe returns 0), andcheck()which runs both. Nothing in it touches the filesystem, the network, or a VM, so the
tests are plain assertions on returned messages.
src/cli_dispatch.rscallsshape::checkin three places 鈥?Start,Restart, andUpafter theBootvalue is assembled 鈥?and skips it for--nativeand--cloud-only, because those paths never create the microVM whose shape is beingvalidated. Failing them on a flag they do not use would be a new bug, not a fix.
src/commands/lifecycle/mod.rs:down --vmconsultsup::running()first andprints one dimmed line when nothing is running, rather than entering
runtime_stopwith no pid to stop.
Evidence
cargo test --locked --bin hanzo shape::鈥?the repo has no lib target, so the bintarget is the one to test:
cargo clippy --locked --bin hanzo鈥?8 warnings, all pre-existing dead code inup/diagnose.rsandvm.rs; none in the new or changed code (shape.rsandcli_dispatch.rsappear in no lint).Each message below is the real output of the release binary on this machine
(
cargo build --locked --release --bin hanzo,hanzo 8.5.1497):Note on the Windows debug binary:
target\debug\hanzo.exe --versionoverflows themain thread stack on this checkout (
thread 'main' has overflowed its stack), on theuntouched
--versionpath as well, so the release build above is what these runsuse. That startup problem is pre-existing and unrelated to this change.
What this does not do
parse_size_mb, so--memory 4096still means MiB and8GiBstill parses as it did; only the resulting bounds are checked.
--cpus/--memory/--diskonhanzo restartstill recreate the VM, as before. Rejecting an impossible shapeearly is the whole change.
--cpusbounds tohanzo vm run, which forwards its own args.Checklist
cargo test --locked --bin hanzogreen (6 new tests)cargo clippy --locked --bin hanzoclean for the new code--native/--cloud-onlyunaffectedCloses #110.
Test environment caveat (Windows)
The full suite on Windows (
cargo test --locked) reports 528 passed / 10 failed,and all ten fail on a clean
maincheckout too — I ran the same filters in agit worktreeofmain(HEAD c3a2655, 8.5.1497) and the same tests fail there:They spawn
shor depend on POSIXPATHresolution, so they need a Linux/macOSrunner; nothing in this PR touches them. The DoD command itself is green on this
branch:
That command needed one small extra commit: eight
dead_codeitems inup/andvm.rsthat are only reachable from the unit tests already failed-D warningsonmain, so they now carry#[allow(dead_code)]with a one-linenote saying exactly that. No behaviour changes, no code deleted.