Repository navigation
feat(ec2): On-Demand Capacity Reservations, with the outcome seedable (#891) - #1032
Merged
Merged
Conversation
…#891) CreateCapacityReservation, DescribeCapacityReservations and CancelCapacityReservation reached the dispatcher's default arm and answered InvalidAction, so a consumer whose probe primitive is an immediate reservation — reserve, read the outcome, cancel — could not run against substrate at all. A reservation is created active, discoverable by ID, by all twelve documented filters, and by tag through DescribeTags (no tag filter is published for this operation, and cr- becomes the sixteenth EC2 ID prefix CreateTags/DeleteTags/ DescribeTags resolve). A capacity failure has two documented observable shapes — a code from EC2's error tables, or a success whose reservation reports a non-nominal state — and which one AWS produces for a given cell is undocumented, so POST/DELETE /v1/ec2/capacity-reservation-outcomes seeds one rather than substrate choosing. A seed naming both is refused. Seeds are scoped to an (instance type, Availability Zone) cell with either half omittable, and the most specific scope carrying a seed decides. Two of the five seedable codes answer a 500-series status because EC2's errors-overview page puts them in its server table; the exact number is unverified, since neither page assigns one. EndDateType is inferred rather than defaulted, expiry is derived at observation time from the simulated clock, and a future-dated reservation (StartDate or CommitmentDuration) is refused with Unsupported rather than answered falsely — eight of the state member's thirteen values belong to a future-dated reservation or a Capacity Block, neither of which substrate models. Nothing consumes a reservation, so availableInstanceCount equals totalInstanceCount for its whole life; ClientToken is accepted and inert. DescribeCapacityReservations refuses an ID list alongside MaxResults, the service-wide rule seven other paginating EC2 describes already apply. Closes #891.
The three prose records overstated the unmodelled part: nothing consumes a reservation, but a cancel does release its capacity, so availableInstanceCount equals totalInstanceCount for as long as the reservation holds capacity rather than for its whole life.
Codecov Report❌ Patch coverage is
📢 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.
CreateCapacityReservation,DescribeCapacityReservationsandCancelCapacityReservationreachedthe EC2 dispatcher's default arm and answered
InvalidAction, although all three are alreadyauthorizable (
authz_reference_gen.go:108,:128,:732) — so a consumer could be grantedpermission to make a call that does not exist. A consumer whose probe primitive is an immediate
reservation — reserve, read the outcome, cancel — could not run against substrate at all.
What it answers
A reservation is created
active, which is what AWS's examples show and what the User Guide states("the reserved capacity becomes available for use immediately after you create it"), and is
discoverable by ID, by all twelve documented filters, and by tag through
DescribeTags.cr-becomes the sixteenth EC2 ID prefix
CreateTags/DeleteTags/DescribeTagsresolve, andTagSpecificationson create usesec2CheckTagSpecificationTypes+ec2LaunchTagsForResourcetogether, so a specification scoped to anything else is refused rather than silently dropped.
Seeding, and why the seed has two halves
The reason a consumer reserves capacity is that capacity is finite, so the observation worth testing
is the one where the request does not succeed — and a capacity failure has two documented
observable shapes: the call fails with a code from EC2's error tables, or it succeeds and the
reservation reports a non-nominal
state(AWS's own words forfailedare "A request can fail dueto request parameters that are not valid, capacity constraints, or instance limit constraints").
Which of the two AWS produces for a given cell is undocumented, so
POST/DELETE /v1/ec2/capacity-reservation-outcomesseeds one rather than substrate choosing; a seed naming bothis refused.
A seed is scoped to an (instance type, Availability Zone) pair — the pair a consumer treats as one
capacity cell — with either half omittable to mean "every", and the most specific scope carrying a
seed decides: cell, then type in any zone, then any type in the zone, then wildcard. Type before
zone is substrate's ordering, since a seed naming an instance type is the narrower claim.
Five codes are seedable and a sixth is refused rather than defaulted, because the HTTP class is the
half substrate cannot derive. Five of the thirteen
statevalues are seedable; a seeded statesurvives into every later describe, unlike a seeded error, which prevents the create from writing
anything at all.
Decisions recorded rather than guessed
EndDateTypeis inferred, not defaulted. AWS publishes noDefault:line and forbids exactlytwo combinations, so an
EndDatealone inferslimitedand noEndDateinfersunlimited.Defaulting to
unlimitedwould turn a request naming only anEndDate, which nothing forbids,into the second refusal.
StartDateandCommitmentDurationanswerUnsupported/400: eight of thestatemember's thirteen values existonly for a future-dated reservation or a Capacity Block, and answering
activeto a request forcapacity two days out would be a false observation with nothing in it to tell a caller the request
was not modelled.
endDate's own sentence,so it is assertable without wall-clock dependence — and only an
activereservation expires,since reporting
expiredfor a seededfailedone would lose the outcome the test seeded.tagSet. No sample response exists for any of the four pages, soan unwritten member follows the shape its neighbours follow; this needs
ec2TagSetXML'spointer-to-wrapper shape, because
xml:"tagSet>item,omitempty"writes the parent anyway.IncorrectStateon a second cancel is substrate's reading. AWS publishes no code forcancelling from a non-cancellable state, and
IncorrectStateis what substrate already answers forthis shape on a volume and a snapshot.
MaxResultscombination is refused viaec2RefuseIDsWithMaxResults, theservice-wide rule seven other paginating EC2 describes already apply, checked before the ID list's
own syntax.
Provenance
InvalidCapacityReservationId.NotFoundand.Malformedare in EC2's client-error table (the casingis AWS's:
Idwith a lowercased).InsufficientInstanceCapacityandRequestLimitExceededarein the server table, so they answer a 500-series status although a consumer reads the first as a
capacity signal — answering 400 would let retry logic pass here and fail in production. The exact
numbers are unverified: neither page assigns one, only a class. The same page contradicts itself
once, writing the throttle code as
Client.RequestLimitExceededin prose while listingRequestLimitExceededin the server table.Verification
gofmt/go build/go vetclean,golangci-lint run ./...0 issues,make testandGOTOOLCHAIN=go1.26.6 make testpass, coverage 85.1% emulator / 84.6% total (baseline 85.0% /84.6%),
docs-reference/docs-reference-check/docs-versions/authz-reference-checkpass, theDocusaurus build passes, and the e2e suite passes.
Closes #891.