Skip to content

feat: host memory preflight — refuse VMs the host cannot back - #22

Merged
raghavendra-talur merged 1 commit into
TheEasyShift:mainfrom
raghavendra-talur:rtalur-memory-preflight
Aug 26, 2026
Merged

feat: host memory preflight — refuse VMs the host cannot back#22
raghavendra-talur merged 1 commit into
TheEasyShift:mainfrom
raghavendra-talur:rtalur-memory-preflight

Conversation

@raghavendra-talur

Copy link
Copy Markdown
Collaborator

Summary

create now fails in one second — with the remedy in the message — instead of thrashing the host or crash-looping vfkit, whenever the requested master RAM plus every live easyshift VM (probed via IsRunning, not the stale persisted state) exceeds physical memory minus a 5120 MiB host reserve.

  • New HostInspector.PhysicalMemoryBytes (sysctl hw.memsize on macOS, /proc/meminfo MemTotal on Linux); a failed probe skips the check (guard, not gate).
  • Reserve calibrated from hardware: on the 24 GiB dev Mac, a 19456 MiB VM ran cleanly and a 20480 MiB VM produced a load-300 swap spiral — 24576 − 5120 = 19456 exactly. The same check subsumes the Virtualization.framework per-VM cap failure (default --master-ram 32768 on small hosts used to crash-loop vfkit and corrupt the boot phase via the install watchdog).
  • Error messages teach: single-VM overflow reports the host's max usable MiB; combined overflow names the running cluster and suggests easyshift stop <name>.
  • Closes both roadmap items (memory preflight; --master-ram vs VZ cap).

Test plan

  • TDD at the app level: oversized single master blocked with --master-ram hint; combined overflow with a running cluster blocked with easyshift stop <name> hint; fits-after-stop passes. make check green.
  • Live on the 24 GiB dev Mac: easyshift create -n memtest (default 32768) now refuses instantly with max usable: 19456 MiB; --odf on the same host likewise refuses cleanly, matching the documented 24 GB limitation.

🤖 Generated with Claude Code

create-master-vms now checks that the new master's RAM plus the RAM of
every other easyshift cluster whose master VM is live (probed, not the
stale persisted state) fits within physical memory minus a 5120 MiB host
reserve, and fails fast with the fix in the message: lower --master-ram,
or easyshift stop <cluster>. Oversubscription never failed cleanly — it
either thrashed the host into a swap spiral (measured: a 20480 MiB VM on
a 24 GiB Mac hit load 300) or, past Virtualization.framework's cap,
crash-looped vfkit at launch while the install watchdog corrupted the
boot phase. The reserve is calibrated from hardware: 24576 - 5120 =
19456 MiB, exactly the largest VM that ran cleanly on the 24 GiB dev
machine. Both roadmap items (memory preflight, VZ cap) close.

HostInspector gains PhysicalMemoryBytes (sysctl hw.memsize / procfs
MemTotal). A failed probe skips the check — it is a guard, not a gate.

Assisted-by: Claude Code/claude-fable-5
Signed-off-by: Raghavendra Talur <raghavendra.talur@gmail.com>
@raghavendra-talur
raghavendra-talur merged commit 579a027 into TheEasyShift:main Aug 26, 2026
2 checks passed
@raghavendra-talur
raghavendra-talur deleted the rtalur-memory-preflight branch August 26, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant