Repository navigation
Bootstrap body: move heredoc comments out of the data; keep 1 KiB of gzip headroom (#1422) - #1429
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…; keep 1 KiB of gzip headroom (#1422) The spored unit and the --command script header carried their rationale as comment lines inside heredocs, which are data, so shellmin keeps them and every launch shipped ~1 KB gzipped of them. They are now shell comments above each heredoc, which shellmin strips. Inline bootstrap 8182 -> 7133 gz of 8192. TestBareBootstrapFitsItsBudget now also requires 1024 bytes spare, and TestMovedHeredocCommentsChangeNothing pins both heredocs as of v0.149.0 and proves the unit's directives and the header's bash tree are unchanged.
scttfrdmn
force-pushed
the
fix/1422-bootstrap-headroom
branch
from
October 29, 2026 20:09
fec7d4c to
ed30ab6
Compare
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.
Fixes #1422
Which paths render the inline bootstrap
Every Linux launcher goes through
launcher.BuildLinuxBootstrap:spawn launch(single, job array, MPI, foreground and detached sweeps, schedules) incmd/launch_config.go,cmd/burst.go,cmd/pool.go, andlauncher.BuildUserData, which servesProvision(lagotto, the MCP server),pkg/tasklaunchand the sweep-orchestrator Lambda's legacy-params path. It inlines the body only whenPublishedBodyVersion()is empty:sporedinstall.ReleaseVersionrejects the version);replaced and that sets nolauncher.CallerVersion;-X main.Version=set to a release (scripts/deploy-sweep-orchestrator.shsets it);sporedinstall.SigningKeyPEMemptied (the key is compiled in by default, so only a deliberate ldflags override does this);InlineBody: true, which nothing in the repo sets (bootstrap_stub_test.gogates that).Windows (
buildWindowsUserData), the web-app user data (cmd/app.go), the pipeline orchestrator andspawn upgrade-sporeddon't render this bootstrap at all. They spliceVerifiedInstallFuncinto scripts of their own, so this budget doesn't cover them.Why the body itself had to shrink
The inline bootstrap is the prefix (variables, signing key, spored pin,
spawn_fatal_retire), then the full published body, then the per-launch files. No logic is inline-only. The body is the same bytes on both paths, and the prefix is needed before the stub can run. So moving logic into the body can't reduce the inline size, and moving more paths onto the stub leaves dev builds where they were. The bytes had to come out of the body.About 1 KB of it was maintainer comments inside two heredocs: the spored systemd unit (#173, #66, restart/stop rationale) and the
/tmp/spawn-command.shheader (#707/#897 errexit history). A comment inside a heredoc is data, soshellmin.Stripcorrectly keeps it, and every launch shipped it into the unit file and the script. Those 31 comment lines are now shell comments directly above each heredoc, which shellmin strips. Nothing else in the body changed: a diff of v0.149.0'sBootstrapBody()against this branch's shows only those 31#lines removed.Sizes (gzip as
TestBareBootstrapFitsItsBudgetmeasures)BootstrapBody())The stub's 2-byte change is the new sha256 hex compressing differently.
The published body's hash changes: sha256
b73c9811fc51ce5ca2b59ffee1a2e3e7ab511a1b2e3de3795419a88d26966b1cto925521a3c0b1707f749eb55cceaef059a526d56a9dbce198e8c389d7f976fc30. Release verification should expect a newspawn/versions/<v>/bootstrap.sh, as it does for every release.Gates
TestBareBootstrapFitsItsBudgetnow also fails when the headroom under the 8 KiB budget is belowbootstrapGzipMargin(1024). Against a compiling revert (origin/main'sbootstrap.go), it fails: "8182 bytes gzipped, 10 under its 8192-byte budget; keep at least 1024 spare".TestMovedHeredocCommentsChangeNothing(new) parses the body with mvdan and finds the heredocs written to/etc/systemd/system/spored.serviceand/tmp/spawn-command.sh. It compares them with the v0.149.0 texts, pinned in the test with their comments: the unit's systemd-visible directives, sections and order must match, and the header must parse to the same bash tree. It passes on origin/main (the pin is that text), and it fails when the move also changes behaviour: deletingNoNewPrivileges=truefrom the unit fails it, and so does changing the header'sset -etoset -eu. Changing either heredoc on purpose means updating its pin.TestBuildLinuxBootstrap_CoreContentasserted that the CRITICAL: PrivateTmp=true hides /tmp/SPAWN_COMPLETE from spored — completion-based on-complete/pre-stop never fire #66 PrivateTmp comment appeared in the rendered script. It now asserts that the comment is in the source beside the unit.cmd'sTestSporedUnit_NoPrivateTmp/AfterNetworkOnline/NoNewPrivilegesstill guard the unit itself and pass.make check,make lint(0 issues, all modules) andsemgrep scan --config=auto --error .(0 findings) pass.go testpasses forpkg/launcher,cmd,pkg/sporedinstall,pkg/tasklaunchandlambda/sweep-orchestrator. No exported API changed, somake api-snapshotisn't needed.