Skip to content

Bootstrap body: move heredoc comments out of the data; keep 1 KiB of gzip headroom (#1422) - #1429

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1422-bootstrap-headroom
Oct 29, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1422-bootstrap-headroom

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

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) in cmd/launch_config.go, cmd/burst.go, cmd/pool.go, and launcher.BuildUserData, which serves Provision (lagotto, the MCP server), pkg/tasklaunch and the sweep-orchestrator Lambda's legacy-params path. It inlines the body only when PublishedBodyVersion() is empty:

  • a dev, pseudo-version or dirty build (sporedinstall.ReleaseVersion rejects the version);
  • a library consumer whose spawn module is replaced and that sets no launcher.CallerVersion;
  • the sweep-orchestrator Lambda built without -X main.Version= set to a release (scripts/deploy-sweep-orchestrator.sh sets it);
  • a build with sporedinstall.SigningKeyPEM emptied (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.go gates that).

Windows (buildWindowsUserData), the web-app user data (cmd/app.go), the pipeline orchestrator and spawn upgrade-spored don't render this bootstrap at all. They splice VerifiedInstallFunc into 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.sh header (#707/#897 errexit history). A comment inside a heredoc is data, so shellmin.Strip correctly 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's BootstrapBody() against this branch's shows only those 31 # lines removed.

Sizes (gzip as TestBareBootstrapFitsItsBudget measures)

before after
inline bare bootstrap 28075 raw / 8182 gz (10 spare of 8192) 25863 raw / 7133 gz (1059 spare)
published body (BootstrapBody()) 25703 raw / 7409 gz 23491 raw / 6349 gz
stub bare bootstrap 4796 raw / 1797 gz (1275 spare of 3072) 4796 raw / 1799 gz (1273 spare)

The stub's 2-byte change is the new sha256 hex compressing differently.

The published body's hash changes: sha256 b73c9811fc51ce5ca2b59ffee1a2e3e7ab511a1b2e3de3795419a88d26966b1c to 925521a3c0b1707f749eb55cceaef059a526d56a9dbce198e8c389d7f976fc30. Release verification should expect a new spawn/versions/<v>/bootstrap.sh, as it does for every release.

Gates

  • TestBareBootstrapFitsItsBudget now also fails when the headroom under the 8 KiB budget is below bootstrapGzipMargin (1024). Against a compiling revert (origin/main's bootstrap.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.service and /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: deleting NoNewPrivileges=true from the unit fails it, and so does changing the header's set -e to set -eu. Changing either heredoc on purpose means updating its pin.
  • TestBuildLinuxBootstrap_CoreContent asserted 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's TestSporedUnit_NoPrivateTmp / AfterNetworkOnline / NoNewPrivileges still guard the unit itself and pass.

make check, make lint (0 issues, all modules) and semgrep scan --config=auto --error . (0 findings) pass. go test passes for pkg/launcher, cmd, pkg/sporedinstall, pkg/tasklaunch and lambda/sweep-orchestrator. No exported API changed, so make api-snapshot isn't needed.

@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

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
scttfrdmn force-pushed the fix/1422-bootstrap-headroom branch from fec7d4c to ed30ab6 Compare October 29, 2026 20:09
@scttfrdmn
scttfrdmn merged commit da8c4a6 into main Oct 29, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1422-bootstrap-headroom branch October 29, 2026 20:33
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.

Inline/bare bootstrap is 10 bytes under its 8 KiB gzip budget: reclaim headroom before the next change

1 participant