Repository navigation
fix(tags): budget tags against AWS's 50-tag limit, and stop emitting duplicate keys - #690
Merged
Merged
Conversation
…duplicate keys The parameter loop capped itself at 35 with a comment claiming that "stays under AWS 50-tag limit", but counted only the sweep parameters and ignored the ~45 tags the other sections had already appended. AWS does not truncate — it rejects RunInstances. Measured on a maximal launch: 46 tags with no parameters, 54 with ten, 79 with sixty. Parameters are now emitted last, budgeted against actual usage, and sorted — the old loop ranged over the map directly, so which parameters survived depended on Go's randomised iteration order and two members of one sweep could record different points in the space. Only parameters are droppable: spawn:* tags are spored's contract (losing spawn:ttl disables TTL enforcement and bills open-endedly), --tag is explicit, and spawn:param:* has an authoritative copy in the sweep manifest. Truncation warns on stderr. Separately, setting both --spot-webhook-url and --completion-webhook-url emitted spawn:webhook-correlation and spawn:webhook-timeout twice, and EC2 rejects the whole call on a repeated key — verified against real EC2. Two flags, no tag arithmetic needed. Tags are now deduped as a pass over the assembled list so a future section cannot forget to. Fixes #477
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Oct 4, 2026
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 #477. Your measurements reproduced, plus a second launch-breaking bug in the same function that needs only two flags.
#477 as filed
Confirmed. A maximal launch (FSx + EFS + both webhooks + job array + sweep + every lifecycle flag):
My numbers differ slightly from yours (46 vs 51 with
Parameters: nil) — I populated the fields that exist on today'sLaunchConfig, and a couple you listed have since moved. The conclusion is unchanged and arguably worse: ten sweep parameters is enough. That is an ordinary sweep, not a pathological one, so this is more reachable than "the maximal-config user".Your diagnosis of why the 35 was a red herring was exactly right, and the budget approach is what I implemented: parameters emitted last, capped against what the launch actually consumed, in sorted order.
The nondeterminism you flagged is fixed and has its own test. It deserved calling out — the old loop ranged over the map directly, so two members of one sweep could record different points in the parameter space, which makes the
spawn:param:*record untrustworthy for exactly the use it exists for.A second bug in the same function
Setting both
--spot-webhook-urland--completion-webhook-urlfails the launch. Both blocks emitspawn:webhook-correlationandspawn:webhook-timeout, and EC2 rejects the entire call on a repeated key. Verified against real EC2 with a dry-run:Two flags, no tag arithmetic. I found it reading the key list while reproducing yours, which is a fair argument for printing the whole list in a test rather than just counting it.
Deduped as a pass over the assembled list rather than by threading a helper through all seven sections, so a section added later cannot forget to use it.
What gets dropped, and why that order
Only parameters. The priority is deliberate, because "truncate something" is not a safe default here:
spawn:*lifecycle tags are spored's contract. Droppingspawn:ttlto fit under the limit produces an instance with no TTL enforcement — a silent, open-ended bill. That is strictly worse than a launch that fails loudly, so these are never dropped. There is a test asserting it under absurd pressure (80 user tags + 80 params).--tagis an explicit request. Dropping what the user typed to make room for a derived tag is backwards.spawn:param:*is a convenience record whose authoritative copy is the sweep manifest — so, as you said, a truncated tag set beats a launch that cannot start.Truncation warns on stderr with the count and the reason, rather than happening silently.
Tests
Five, each confirmed to fail against the old code:
35cap fails at 10, 35 and 60 paramsspawn:ttl,spawn:cost-limit,spawn:on-completeand friendsGates
gofmt -lempty,go vet ./...,go test -short ./...,make check-docs, changelog gate,semgrep→ 0 findings.Not hardware-verified, and I don't think it needs to be: the tag-count assertions are pure, and the one behaviour only AWS can confirm — that a duplicate key is rejected — I confirmed with a
run-instances --dry-runagainst real EC2 rather than reasoning about it.make smoke-neededflagspkg/aws/as hardware-sensitive, and a launch smoke before the next tag would cover the composed path.Thanks for measuring it rather than reasoning about it, and for porting the fix shape from spawn-ts — having the budget/sorted-order design already proven there made this a much shorter job.