Repository navigation
fix(ec2): refuse an unmodelled instance type, and make the offerings filter work (#485) - #496
Merged
Merged
Conversation
…filter work (#485) Three defects, all in the instance-type operations. DescribeInstanceTypes answered an unknown type with HTTP 200 and an empty list where real us-east-1 raises InvalidInstanceType, so a consumer validating a user-supplied type got no signal and their validation branch was unreachable. InstanceType.N asserts the types exist, so every unknown one is collected into a single bracketed list in request order and one bad type fails the whole request. The code is documented; the message is verbatim from the capture in #485, whose list separator is substrate's choice. DescribeInstanceTypeOfferings' instance-type filter had never worked: it read an InstanceType.N parameter the operation does not have, so the filter map was always empty and every query returned the whole catalog in every zone. Both documented filter names now apply, with EC2's wildcards (* zero-or-more, ? zero- or-one, \ to escape), case-sensitive values, Value.M as an OR and Filter.N ANDed. Any other name is refused rather than ignored -- including location-type, which is not a filter. LocationType is honoured as the parameter it is; availability-zone-id and outpost are refused with a message naming substrate instead of being answered with zone names under a contradictory locationType. An unmatched filter stays an empty answer at HTTP 200, deliberately opposite to InstanceType.N and confirmed by #485's diff of both. Both halves are pinned so neither can later be tidied into consistency with the other. The catalog is widened from 8 types to 57 whole families, which is what makes refusing an absent type honest: stopping at c5.xlarge would answer InvalidInstanceType for c5.large. Spot prices are generated from the same table as the specs, so the type-in-catalog-but-not-in-price-map hazard is gone, and the eight prices #234 shipped are preserved verbatim. The three zone-name sites now share one list.
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.
Closes #485
All three of #485's items, in one PR because they depend on each other: refusing a
type the catalog lacks is only honest once the catalog holds whole families.
1.
DescribeInstanceTypesrefuses an unknown typeAn unknown type was answered with HTTP 200 and an empty list. Real
us-east-1raises
InvalidInstanceType/ 400. This is the #391 shape again — an empty list isindistinguishable from "the type exists but matched nothing", so a consumer
validating a user-supplied instance type has an unreachable error branch.
Every unknown type in the request is collected into one bracketed list, in request
order, and one bad type fails the whole request:
InstanceType.Nis an assertionthat the supplied types exist, so a partial answer would let a caller checking only
the result set miss the bad input.
Provenance is split. The code is from EC2's client-error table. The message is
verbatim from the single real-
us-east-1capture in #485, so the brackets andplural phrasing are observed; the
", "separator for a multi-type list is notcorroborated and is substrate's choice.
2. The offerings
instance-typefilter now worksIt had never worked. The handler built its filter from an
InstanceType.Nparameter the operation does not have — the reference lists exactly
DryRun,Filter.N,LocationType,MaxResults,NextToken, and botocore rejectsInstanceTypesoutright. So the filter map was always empty and every queryreturned the whole catalog in every zone: "is
m5.xlargeoffered here?" answeredyes for any input. The pattern was copied from
DescribeInstanceTypes, where theparameter does exist.
Both documented filter names now apply, with EC2's documented wildcards (
*zeroor more,
?zero or one,\escapes), case-sensitive values, allFilter.N.Value.Mas an OR and separateFilter.NANDed.path.Matchis unusablehere: its
?matches exactly one character.Any other filter name is refused, not ignored — silently dropping a filter is
how this went unnoticed for four releases. That includes
location-type, which#485's aside believed was a filter name; it is not, and a test pins the rejection.
LocationTypeis honoured as the top-level parameter it is:availability-zone(default) and
region.availability-zone-idandoutpostare real AWS valuessubstrate does not model and are refused with a message naming substrate — treating
either as
availability-zonewould return zone names under alocationTypeclaiming they are IDs or Outpost ARNs.
An unmatched filter is 0 offerings at HTTP 200, deliberately the opposite of
InstanceType.Nand confirmed by #485's real-AWS diff of both. A filter narrows aresult set;
InstanceType.Nasserts existence. Both halves are pinned so neithercan later be "tidied" into consistency with the other.
3. The catalog covers whole families
8 types → 57. The old catalog split families mid-way (
c5.xlargein,c5.largeout), which was incidental to #234's consumer and becomes a correctness problem the
moment an absent type is refused.
t3,t3a,m5,m5a,c5,c5a,r5arecomplete — note
c5's ladder differs fromc5a's (9xlarge/18xlargevs8xlarge/16xlarge) — plus the three accelerated sizes. All ten types #485 namesare present; five were not. Bare metal is excluded, pinned by a test.
Spot prices are generated from the same per-family table as the specs, so the
old parallel-map hazard is gone (
DescribeSpotPriceHistorysilently dropped anytype absent from the price map). The eight prices #234 shipped are preserved
verbatim so no recorded fixture moves. The three zone-name sites share one list, so
filtering an offerings query by a zone
DescribeAvailabilityZonesjust reportedcannot return empty.
Verification
gofmt,go build,go vet,golangci-lint run ./...(0 issues),make test(race),
make docs-reference docs-reference-check docs-versions, VitePress build,go test -C test/e2e ./...— all clean.Mutation tested: 27 mutations, 27 caught, 0 survived. Including both directions
the plan called for — returning empty instead of
InvalidInstanceType, andraising on an unmatched offerings filter — plus counting
?as exactly-one,case-insensitive matching, byte-vs-rune, a mid-family catalog split, bare metal
re-added, a moved seeded price, and the offerings zone list diverging from
DescribeAvailabilityZones.End to end against
substrate server: 57 types; 171 = 57×3 offerings unfiltered;LocationType=region→ 57 at one location;m5.xlarge→ 3;zz9.bogus→ 0 at200;
zz9.nonexistent→ 400InvalidInstanceType;location-type→ 400;outpost→ 400 naming substrate;t3.microprice still0.0042.Follow-up filed
#495 —
DescribeInstanceTypesignoresFilter.Nentirely. The operation documents~60 filter names, nearly all over fields the seeded catalog does not carry;
applying the answerable handful and dropping the rest would be this same
silent-narrowing defect. Marked with a
TODO(#495)rather than half-done.