Skip to content

install/restore: auto-fallback to host TFTP when pod PSRAM is too small#95

Merged
widgetii merged 1 commit into
masterfrom
auto-fallback-pod-to-host
May 12, 2026
Merged

install/restore: auto-fallback to host TFTP when pod PSRAM is too small#95
widgetii merged 1 commit into
masterfrom
auto-fallback-pod-to-host

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

  • defib install/restore --tftp-via=auto (the default when power=rack) now does a pre-flight GET /tftp on the pod and falls back to host TFTP if psram_largest_free_block < total_bytes + 256 KiB headroom — instead of crashing partway through the staging POST with a 503 OOM.
  • Strict --tftp-via=pod is unchanged — 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) -> (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 in TestPsramCanFit
  • uv run pytest tests/ -x --ignore=tests/fuzz — full suite clean
  • uv run ruff check src/ tests/ — clean
  • uv run mypy src/defib --ignore-missing-imports — clean
  • Live against pod 10.216.128.69:
    • 6 MB filler staged → largest_free=2 MBauto falls back: "Pod PSRAM has 2016 KB contiguous free, need 6535 KB ..."
    • same condition with --tftp-via=pod → 503 OOM (strict mode preserved)
    • cleared pod (DELETE /tftp) → auto uses pod path normally

🤖 Generated with Claude Code

`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>
@widgetii widgetii merged commit 89576b4 into master May 12, 2026
13 checks passed
@widgetii widgetii deleted the auto-fallback-pod-to-host branch May 12, 2026 05:54
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