Skip to content

feat(ec2): stamp aws:ec2:fleet-id on fleet instances (#443) - #447

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/443-fleet-id-tag
Aug 1, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/443-fleet-id-tag

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Problem

CreateFleet launched its instances through runInstances but never tagged them with the fleet that created them, so there was no route from a fleet ID back to its instances.

For an instant fleet that tag is the only route:

  • DescribeFleetInstances rejects instant fleets outright.
  • The fleetInstanceSet a fleet response echoes is a record of what was launched, not what is running — it never drops terminated instances.

So a consumer enumerating an instant fleet saw a fully-provisioned, running fleet as empty. That reads as "the instances are gone" rather than "substrate didn't record this", which is why the reporter debugged their own code first.

Change

fleetIDTagSpec appends aws:ec2:fleet-id to the synthetic RunInstances params launchFleetPool already builds, at an index past whatever passthroughFleetTagSpecs emitted — that function renumbers its output from 1, and reusing an occupied TagSpecification index would silently overwrite a caller's own launch-time tag. It runs per pool, so a multi-pool fleet tags all of its instances.

Source note

Stated plainly, because CLAUDE.md makes AWS docs authoritative: aws:ec2:fleet-id appears in neither the EC2 API reference nor the fleet tagging/describe/delete user-guide pages. The authority is observed real-AWS behavior reported by the parsl-aws-provider consumer, whose get_ec2_fleet_instance_ids() is built on it — not a documented API contract. That provenance is recorded in the code comment, docs/services.md and the changelog rather than implied away.

What is documented authoritatively, and noted in the docs: the aws: prefix is reserved, such a tag cannot be edited or deleted by a caller, and it does not count against the 50-tag limit.

Deliberately out of scope

CreateTags still accepts an aws:-prefixed key that real EC2 rejects with InvalidParameterValue. That acceptance is currently the workaround this change removes the need for, so tightening it in the same release would break the reporter on upgrade with no overlap window. Filed as a follow-up.

Tests

Five tests in emulator/ec2_fleet_test.go:

  • the tag lands on every launched instance with the returned FleetId
  • DescribeInstances --filters tag:aws:ec2:fleet-id returns exactly one fleet's instances — the assertion that actually matters, and it also pins that the colon-bearing key survives the filter's tag: prefix cut rather than being split on every colon
  • caller TagSpecification tags survive alongside the reserved tag, and the fleet-scoped tag still does not leak (the regression the index arithmetic can break)
  • multi-pool fleet tags instances from both pools
  • a fully-unfulfilled fleet succeeds and returns no instances

Each was mutation-tested: with the fix removed, four of the five fail.

Verification

gofmt, go build, go vet, golangci-lint run ./... (0 issues), make test (race), test/e2e, make docs-reference-check docs-versions — all clean.

Closes #443

CreateFleet launched its instances through runInstances but never tagged
them with the fleet that created them, so there was no route from a fleet
ID back to its instances.

For an instant fleet that tag is the only route: DescribeFleetInstances
rejects instant fleets outright, and the fleetInstanceSet a fleet response
echoes is a record of what was launched rather than what is running — it
never drops terminated instances. A consumer enumerating an instant fleet
therefore saw a fully-provisioned, running fleet as empty, which reads as
"the instances are gone" rather than "substrate didn't record this".

fleetIDTagSpec appends the tag past whatever passthroughFleetTagSpecs
emitted, because that function renumbers its output from 1 and reusing an
occupied TagSpecification index would silently overwrite a caller's own
launch-time tag. It runs per pool, so a multi-pool fleet tags all of its
instances.

Source note, stated plainly because CLAUDE.md makes AWS docs
authoritative: aws:ec2:fleet-id appears in neither the EC2 API reference
nor the fleet tagging/describe/delete pages. The authority here is
observed real-AWS behavior reported by the parsl-aws-provider consumer,
whose fleet-to-instance lookup is built on it — not a documented API
contract. That provenance is recorded in the code comment, the docs and
the changelog rather than implied away.

Deliberately out of scope: CreateTags still accepts an aws:-prefixed key
that real EC2 rejects with InvalidParameterValue. That acceptance is
currently the workaround this change removes the need for, so tightening
it in the same release would break the reporter on upgrade with no
overlap window. Tracked as a follow-up.

Tests cover the tag landing on every instance, the DescribeInstances
tag:aws:ec2:fleet-id filter returning exactly one fleet's instances (which
also pins that the colon-bearing key is not split by the filter's prefix
cut), coexistence with caller tags, multi-pool fleets, and a fully
unfulfilled fleet. Each was mutation-tested against the unfixed code.

Closes #443
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/ec2_fleet.go 86.66% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 713e612 into main Aug 1, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the feat/443-fleet-id-tag branch August 2, 2026 22:01
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.

EC2: CreateFleet does not apply the aws:ec2:fleet-id tag, so a fleet's instances can't be found

1 participant