install/restore: auto-fallback to host TFTP when pod PSRAM is too small#95
Merged
Conversation
`defib install/restore --tftp-via=auto` (the default when power=rack)
now does a pre-flight `GET /tftp` and compares the pod's
`psram_largest_free_block` against the total bytes the install needs.
If the pod can't fit the firmware in one contiguous block, it falls
back to host TFTP and prints a single yellow line explaining why —
rather than failing partway through the staging POST with a 503 OOM.
Strict `--tftp-via=pod` is unchanged: it still errors on OOM, since
the user explicitly opted out of the host path.
New `RackController.psram_can_fit(total_bytes, headroom_bytes=256 KiB)`
queries `/tftp` and returns `(fits, stats)`. Any transport error
returns `(False, {})` so the CLI treats an unreachable pod the same as
"won't fit" and cleanly falls back instead of crashing the pre-check.
Tested live against pod at 10.216.128.69:
- 6 MB filler staged → largest_free=2 MB → `auto` falls back with
"Pod PSRAM has 2016 KB contiguous free, need 6535 KB ..."
- same condition with `--tftp-via=pod` → 503 OOM (correct strict mode)
- cleared pod → `auto` uses pod path normally
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
defib install/restore --tftp-via=auto(the default whenpower=rack) now does a pre-flightGET /tftpon the pod and falls back to host TFTP ifpsram_largest_free_block < total_bytes + 256 KiBheadroom — instead of crashing partway through the staging POST with a 503 OOM.--tftp-via=podis unchanged — still errors on OOM, since the user explicitly opted out of the host path.RackController.psram_can_fit(total_bytes, headroom_bytes=256 KiB) -> (bool, stats)— any transport error returns(False, {})so an unreachable pod is treated the same as "won't fit", and the CLI cleanly falls back rather than crashing the pre-check.Test plan
uv run pytest tests/test_power_rack.py -x -v— 29 pass, 4 new inTestPsramCanFituv run pytest tests/ -x --ignore=tests/fuzz— full suite cleanuv run ruff check src/ tests/— cleanuv run mypy src/defib --ignore-missing-imports— clean10.216.128.69:largest_free=2 MB→autofalls back: "Pod PSRAM has 2016 KB contiguous free, need 6535 KB ..."--tftp-via=pod→ 503 OOM (strict mode preserved)DELETE /tftp) →autouses pod path normally🤖 Generated with Claude Code