Repository navigation
feat(ec2): CreateFleet with seedable partial fulfillment; wire four CFN resource types (#387, #388, #389) - #390
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
ffa4044 to
f165d64
Compare
…FN types (#387, #388, #389) EC2 Fleet (#387) ---------------- Add CreateFleet, DescribeFleets, and DeleteFleets. Instances launch through the same runInstances path as a direct launch, so they are visible to DescribeInstances with subnet/security-group validation, placement groups, and launch-time tag propagation intact. LaunchTemplateConfigs[] x Overrides[] flatten into ordered capacity pools (sorted by Priority under a prioritized allocation strategy) and are fulfilled round-robin, so fleetInstanceSet carries one item per pool each with a *list* of instance IDs — the shape callers most often flatten incorrectly. An instant fleet returns instances and errors synchronously; request/maintain fleets return only the fleet ID, matching AWS. Partial fulfillment is seedable via POST/DELETE /v1/ec2/fleet-shortfall, keyed by launch-template ID/name or "*". A fleet that asks for 12 and receives 8 still returns a fleet ID and echoes the *request* in TotalTargetCapacity, so this is where callers most often go wrong — and it is rare and hard to trigger against real AWS. Seeding makes it instant and reproducible; the shortfall is reported per pool in errorSet with a configurable code and lifecycle. CFN wiring (#388) ----------------- Four resource types had working API handlers but fell through to deployGenericStub, so a stack deployed "successfully" while the resource was never created: - AWS::EC2::LaunchTemplate — Ref is the real lt-… ID, usable by CreateFleet - AWS::IAM::InstanceProfile — creates the profile and attaches each Roles entry - AWS::EC2::SecurityGroupIngress / ::SecurityGroupEgress — standalone rules, resolving Source/DestinationSecurityGroupId through Ref/GetAtt AWS::EC2::SecurityGroup now also authorizes its inline SecurityGroupIngress/ Egress rules, which were parsed but never applied — so previously *neither* spelling produced rules, and DescribeSecurityGroups reported an empty group regardless of how the template was written. This needed a type change: EC2IPPermission had no way to express a rule whose source is another security group (a self-referencing rule has no CIDR at all). Added UserIDGroupPairs, parsing of IpPermissions.N.Groups.M.GroupId, and groups>item rendering in DescribeSecurityGroups. While there, the rule parser now reads every IpPermissions.N entry and all of each entry's IpRanges.M rather than only the first of each, and revoke matches on source as well as ports. AWS::EC2::Instance passes through IamInstanceProfile, KeyName, and SecurityGroupIds — the profile reference is only resolvable now that AWS::IAM::InstanceProfile creates a real profile. The generic-stub warning reports whether the type's service plugin is loaded; it previously read as "substrate doesn't model this", misleading when the actions exist and only the wiring is missing. AWS::EC2::NetworkInterface is left stubbed — it needs a CreateNetworkInterface handler first, which #388 notes belongs in its own issue. Docs (#389) ----------- emulator/doc.go claimed 39 plugins and 23 S3 operations; the registry has 63 and s3_plugin.go 53. The counts that #364 made generated had drifted here, so doc.go now points at the generated docs/services.md rather than repeating a number that can drift. CLAUDE.md's key-files table pointed at four paths that moved to emulator/ in the #310 reorg and pinned a now-stale next version. All wire shapes were verified against the AWS API reference: the XML elements are fleetId/fleetInstanceSet/errorSet (not the boto3-facing names), and source security groups use IpPermissions.N.Groups.M.GroupId. Closes #387 Closes #388 Closes #389
f165d64 to
789404e
Compare
|
Rebased onto
One entry corrected. The #389 Verification on the rebased commit: Not reviewed for correctness here — this was a rebase to make the PR mergeable again. Its three issues (#387, #388, #389) are on the v0.77.0 milestone, which is still open. |
Sprint covering #387, #388, and #389.
#387 — EC2
CreateFleetAdds
CreateFleet,DescribeFleets,DeleteFleets.Instances launch through the same
runInstancespath as a direct launch, so they are visible toDescribeInstanceswith subnet/security-group validation, placement-group checks, and launch-time tag propagation intact.LaunchTemplateConfigs[]×Overrides[]flatten into ordered capacity pools (sorted byPriorityunder aprioritizedallocation strategy) and are fulfilled round-robin, sofleetInstanceSetcarries one item per pool, each with a list of instance IDs — the shape the issue flags as the classic caller bug. Aninstantfleet returns instances and errors synchronously;request/maintainreturn only the fleet ID, matching AWS.Partial fulfillment is seedable — the valuable part:
A fleet that asks for 12 and receives 8 still returns a fleet ID and echoes the request in
TotalTargetCapacity, never the result — which is exactly why callers get it wrong, and it is rare and hard to trigger against real AWS. The shortfall is spread across pools, soerrorSetreports one item per short pool, andDescribeFleetsreports the truth infulfilledCapacity. Seeds are keyed by launch-template ID/name or\"*\", following the established pattern (ssm_control.go).#388 — four CFN types fell to the generic stub
The handlers existed; the wiring didn't, so a stack deployed "successfully" while the resource was never created.
AWS::EC2::LaunchTemplateCreateLaunchTemplatelt-…ID, usable byCreateFleetAWS::IAM::InstanceProfileCreateInstanceProfile+AddRoleToInstanceProfileperRolesentryAWS::EC2::SecurityGroupIngressAuthorizeSecurityGroupIngressAWS::EC2::SecurityGroupEgressAuthorizeSecurityGroupEgressAWS::EC2::SecurityGroupnow also authorizes its inlineSecurityGroupIngress/SecurityGroupEgressrules. Previously neither spelling produced rules, soDescribeSecurityGroupsreported an empty group however the template was written — the case the issue calls sharpest.That needed a type change the issue didn't anticipate:
EC2IPPermissionhad no way to express a rule whose source is another security group, and a self-referencing rule has no CIDR at all. AddedUserIDGroupPairs, parsing ofIpPermissions.N.Groups.M.GroupId, andgroups>itemrendering. While in the parser: it now reads everyIpPermissions.Nentry and all of each entry'sIpRanges.M(it previously read only the first of each), and revoke matches on source as well as protocol/ports, so revoking a CIDR rule no longer removes a source-group rule on the same port.AWS::EC2::Instancepasses throughIamInstanceProfile,KeyName, andSecurityGroupIds— the profile reference is only resolvable now that the profile is real.The generic-stub warning reports
service_plugin_loaded, the issue's suggested cheap improvement; it previously read as "substrate doesn't model this", misleading when only the wiring is missing.AWS::EC2::NetworkInterfaceis left stubbed — it needs aCreateNetworkInterfacehandler first, which the issue notes belongs in its own issue.#389 — doc drift
emulator/doc.goclaimed 39 plugins and 23 S3 operations; the registry has 63 ands3_plugin.go53. The counts #364 made generated had drifted here, sodoc.gonow points at the generateddocs/services.mdrather than repeating a number that can drift.CLAUDE.md's key-files table pointed at four paths that moved toemulator/in the #310 reorg. (The stale next-release pin flagged in the same issue was already removed while cutting v0.81.0, so this PR no longer claims it.)Verification
All wire shapes checked against the AWS API reference per CLAUDE.md, which caught two things worth noting:
fleetId/fleetInstanceSet/errorSet, not the boto3-facingInstances/Errorsnamed in EC2: no CreateFleet handler (partial-fulfillment semantics are the interesting part) #387.IpPermissions.N.Groups.M.GroupId.23 new fleet subtests + 7 new CFN tests, covering full/partial/zero fulfillment, pool prioritization, spot lifecycle, tag propagation, error cases, instant-fleet visibility rules, delete with and without
TerminateInstances, self-referencing and mutually-referencing security groups, and launch-template →CreateFleetcomposition.make test(race),test/e2e,go vet,golangci-lint run ./...(0 issues), andmake docs-reference-checkall green.Closes #387
Closes #388
Closes #389