Repository navigation
chore: untrack the 22 MiB lambda binary and gate against tracked executables - #644
Merged
Merged
Conversation
…utables
lambda/autoscale-orchestrator/autoscale-orchestrator was the single name missing
from .gitignore's hand-maintained per-lambda list, so it was tracked and
mutable. A plain `go build ./...` in that module — which CI itself runs on every
lambda module — rewrote it, and `git add -A` then staged a 22 MiB diff. That
happened to me twice in one session, which is what makes it a live footgun
rather than cosmetic debt.
Verified nothing depended on the path before deleting it:
- The Makefile builds `bootstrap` (BINARY_NAME=bootstrap) and zips that;
`clean` removes bootstrap and function.zip and does not know this file
exists.
- Every other reference to "autoscale-orchestrator" in the repo is the Lambda
FUNCTION name (spawn-autoscale-orchestrator-${Environment}) or the sts
ExternalId — not a file path.
- The committed bytes are Mach-O arm64, i.e. a macOS build. The function is
provided.al2023/arm64 Linux, so this binary could never have run on Lambda
at all.
Also found: template.yaml uses `CodeUri: .` with no .samignore, so SAM packages
the whole directory — the dead 22 MiB binary has been riding inside every
deployed artifact (the directory is 22M, essentially all of it this file).
Deliberately NOT changing deploy packaging here; noted on the issue instead,
since I can't exercise a sam deploy to prove a .samignore safe.
Two gates replace the hand-maintained list as the actual protection:
- TestNoTrackedCompiledBinaries — fails if any tracked file is a compiled
executable. Matches MAGIC BYTES, not `file` output: `file` describes every
shell and Python script here as "... text executable", and there are 20+ of
those under lambda/ alone, so a substring check would fail on all of them.
Exactly one file in the repo matched before this change.
- TestEveryGoLambdaBinaryIsIgnored — fails if a Go lambda module has no
.gitignore entry for its build output, catching the omission at the source
instead of after a binary is committed. Scoped to modules with a go.mod, so
the Python github-oauth lambda (handler.py, no Go build) isn't flagged.
Both confirmed to fail when inverted: re-adding the binary trips the first, and
deleting the ttl-reaper line trips the second.
Removing this from HEAD does not shrink existing clones — the bytes remain in
history — but it stops the bleeding. A history rewrite isn't worth it.
Fixes #637
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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 #637.
What was wrong
lambda/autoscale-orchestrator/autoscale-orchestratorwas the one name missing from.gitignore's hand-maintained per-lambda list, so it was tracked and mutable. A plaingo build ./...in that module — which CI itself runs on every lambda module — rewrote it, andgit add -Athen staged a 22 MiB diff. That caught me twice in one session, which is what makes it a live footgun rather than cosmetic debt.Checked before deleting
The issue flagged that a tracked binary "suggests something may have depended on it", so that came first:
bootstrap(BINARY_NAME=bootstrap) and zips that.cleanremovesbootstrapandfunction.zipand doesn't know this file exists.autoscale-orchestratorreference in the repo is the Lambda function name (spawn-autoscale-orchestrator-${Environment}) or the stsExternalId— never a file path.provided.al2023/arm64 Linux, so this binary could never have run on Lambda to begin with. It's definitively dead.Found while verifying
template.yamlusesCodeUri: .with no.samignore, so SAM packages the whole directory — meaning this dead 22 MiB binary has been riding inside every deployed artifact. (du -shon the directory is 22M, essentially all this one file.)I deliberately did not change deploy packaging here. Adding a
.samignoretouches how a real Lambda gets built and I can't exercise asam deployto prove it safe, so it's noted on the issue as a separate item rather than smuggled into a cleanup PR.The gates
The issue's option 1 suggested generalising the
.gitignorepattern. That isn't expressible —go buildnames output after the module directory, so the pattern islambda/<name>/<name>and gitignore can't say "same name as parent". So the.gitignoreline stays explicit, and the generalisation lives in tests instead (the issue's option 3):TestNoTrackedCompiledBinaries— fails if any tracked file is a compiled executable. Matches magic bytes, notfileoutput:filedescribes every shell and Python script here as"... text executable", and there are 20+ of those underlambda/alone (deploy.sh,handler.py, the dashboard-api setup scripts), so a substring check on "executable" would fail on all of them — which is how a gate like this gets deleted instead of fixed. Scanned repo-wide: exactly one file matched before this change.TestEveryGoLambdaBinaryIsIgnored— fails if a Go lambda module has no.gitignoreentry for its build output, catching the omission at the source rather than after a binary is already committed. Scoped to modules with ago.mod, so the Pythongithub-oauthlambda (handler.py, no Go build) isn't flagged — my first pass reported it as missing, which was a false alarm.Both confirmed to fail when inverted: re-adding the binary trips the first (
Mach-O 64-bit), deleting thettl-reaperline trips the second.Scope note
Removing this from
HEADdoes not shrink existing clones — the bytes stay in history. It stops the bleeding; a history rewrite isn't worth it, as the issue says.Verification
gofmt,go vet, fullgo test -short ./..., changelog gate — all green.go build ./...inlambda/autoscale-orchestratornow leavesgit statusclean.--config=auto --error): 0 findings..gofile is a_test.go, so the changelog gate doesn't fire — I added an entry anyway, since a 22 MiB removal is worth recording for contributors.