Repository navigation
[Nexthop][feature] fboss-image: root filesystem headroom guard before platform_manager - #1892
Open
sazeed-nexthop wants to merge 1 commit into
Open
sazeed-nexthop wants to merge 1 commit into
sazeed-nexthop wants to merge 1 commit into
Conversation
…_manager On a boot with / full, rpm and dnf cannot open the rpmdb (rpm's sqlite backend runs a write transaction on open and dies with SIGBUS below ~128 KB free), so platform_manager, and everything ordered after it, fails. Nothing in the image frees space before the stack starts, and btrfs has no root-reserved blocks, so root daemons get no headroom once the disk fills. Add fboss_disk_guard.service, a oneshot ordered before platform_manager.service (which Wants= and After= it). When free space on / is below MIN_FREE_KB (100 MB) it logs an FBOSS_ALERT and frees, in order, the journal (vacuum to 16 MB), systemd coredumps and rotated logs under /var/log, then deletes a preallocated ballast file (/var/lib/fboss/.ballast, sized to the threshold). It re-polls df after each step because btrfs releases unlinked extents asynchronously, and stops at the first step that recovers. On a healthy boot with at least 10x the threshold free it recreates the ballast. It always exits 0 and never writes to disk itself. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
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.
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runSummary
Companion to #1890. That PR makes platform_manager survive an unreadable rpmdb. This one keeps headroom on
/before platform_manager starts, so that rpm, dnf and the rest of the stack can run at all on a full-disk boot. The two are independent and can land in either order.Problem
When a switch running the distro image reboots with
/full, the FBOSS stack does not come back:rpm -qanddnf list --installedwork at 128 KB free and die with SIGBUS (exit 135) at 64 KB.StartLimitBurst=5). With no/run/devmap, led_service and qsfp_service crash-loop behind it, each restart dumping core onto the full disk.Change
A small oneshot service,
fboss_disk_guard, runs before platform_manager:/has at leastMIN_FREE_KBfree (default 100 MB), it exits. If the ballast file is missing and at least 10x the threshold is free, it creates it first.FBOSS_ALERT <event:low_disk_space>, then frees things the image owns, in order, stopping at the first step that gets back above the threshold:journalctl --vacuum-size=16M/var/lib/systemd/coredump/var/log(*.gz,*.N,*.old)/var/lib/fboss/.ballastsized to the thresholdlow_disk_space_recoveredwith the step that worked, orlow_disk_space_unrecovered, and always exits 0 so platform_manager starts regardless.The ballast is what makes recovery deterministic. Steps 1 to 3 free whatever happens to be there, which may be nothing if the disk was filled by something else. The ballast is space reserved up front that can always be given back. It is effectively the btrfs substitute for ext4's reserved blocks.
Files
root_files/usr/local/bin/fboss_disk_guard.sh: the script. It re-pollsdffor up to 10 s after each step, because btrfs releases unlinked extents asynchronously. It never writes to disk itself, and it only touches the paths listed above. There is no dnf step, since dnf cannot run on a full disk.root_files/usr/lib/systemd/system/fboss_disk_guard.service:Type=oneshot,RemainAfterExit=yes,Before=platform_manager.service.platform_manager.service: addsWants=andAfter=fboss_disk_guard.service. Because ofWants=,systemctl disablealone does not stop the guard;systemctl maskdoes.config.sh:systemctl enable fboss_disk_guard.service.Test Plan
pre-commit runpasses, including shellcheck and shfmt on the new script.On hardware, a Wedge800BNHP (Tomahawk5, kernel 6.11) on a freshly installed distro image.
/was filled to 64 KB free withfallocateanddd. Coredumps and the journal were cleared beforehand, so the ballast was the only thing left to free. Then the switch was rebooted:Recovered 64KB -> 102464KB via: rm -f /var/lib/fboss/.ballast/run/devmap/xcvrs/after bootThe same result was seen with the guard combined with #1890: the guard recovers first, and platform_manager never sees the failure.
On a healthy boot with ample free space, the guard creates the 100 MB ballast once and exits without an alert.
🤖 Generated with Claude Code