Repository navigation
fix(launcher): strip comments from the bootstrap's user data (#1246) - #1273
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
Author
|
Booted live from this branch in the dev account, us-west-2, on 2026-10-23:
|
This was referenced Oct 23, 2026
Merged
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 #1246
The spored bootstrap's static script text was 39 KB raw, and 16.5 KB of that was comments. Gzipped, the bootstrap alone was 12.8 KB of EC2's 16 KiB user-data limit. A trivial
spawn task runused 14,711 bytes, leaving about 1.7 KB for a task's own command.Change
New package
internal/shellmin.Stripdrops whole-line comments and blank lines and keeps every other line byte for byte. Heredoc bodies are kept whole: quoted, unquoted and<<-are tracked, and a<<<here-string is not mistaken for a heredoc.BuildLinuxBootstrapstrips only spawn's own five static templates:Caller content (command, storage, container and custom user data) is added as given.
bash -c 'echo hi'task, gzipped user dataspawn task run --dry-run, real AWS, us-west-2)A task now has about 7.2 KB of headroom instead of 1.7 KB.
Gates
TestMinifiedTemplatesParseTheSameparses each template with mvdan.cc/sh (the shfmt parser) before and after stripping. It prints both, comment-free and minified, and requires them to be identical. SoStripmust remove nothing but comments, blank lines and layout. With heredoc tracking disabled, it fails on the real bootstrap body, not just on the unit cases.TestEveryStrippedTemplateIsCheckedreadsbootstrap.go'sshellmin.Stripcalls from its AST, so a template added later cannot skip that gate. A sixth call fails it.TestMinifyShellKeepsDatacovers the edge cases: heredocs (quoted, unquoted,<<-), the here-string, and trailing comments, which are kept.TestBareBootstrapFitsItsBudgetsets an 8 KiB gzipped budget for the bare bootstrap, as the issue suggests. Growth past it now needs a review decision.Test changes
Three bootstrap tests located script sections by comment text (
# Decode and write SSH public key,# Create login banner). They are now anchored on code.TestBurstMembersInstallAndVerifySporedcompares against the stripped install function.mvdan.cc/sh/v3 is a test-only dependency. Runtime stripping is a line filter, and no lambda module's go.mod changes.
Checks run
go test -short ./...: pass.make lint: clean in all 10 modules.Not yet validated on a real instance boot.