Repository navigation
fix(ec2): a subnet reports its tags and filters on them; a snapshot honours its own (#685) - #699
Merged
Merged
Conversation
…onors its own (#685) DescribeSubnets parsed no Filter.N at all and rendered no tagSet, so "the subnets of vpc-x" answered with every subnet in the region and every tag a caller had applied to a subnet was stored and invisible. DescribeSnapshots evaluated one of the fourteen names its reference documents and read neither Owner.N nor RestorableBy.N. CreateSubnet now honors TagSpecification.N scoped to subnet, under the same reserved-prefix and 50-tag rules every other tag path enforces, and both subnet operations render one shared Subnet element — they previously rendered different subsets of it. The element gains tagSet, subnetArn, ownerId and defaultForAz; tagSet is absent on an untagged subnet, per both of AWS's samples for this operation. DescribeSnapshots applies ten of its fourteen filters, the other four naming members substrate does not render, and honors Owner.N/RestorableBy.N with single-account semantics: self and the own account match everything, amazon and any other account match nothing. Also deletes the EC2 plugin's last two function-local tagItem copies and unifies the subnet ARN behind ec2SubnetARN, which the subnet-arn filter, the response and the authorization resolver now all share.
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 #685.
DescribeSubnetsparsed noFilter.Nat all and rendered notagSet, so a request for"the subnets of
vpc-x" answered with every subnet in the region — with nothing in theresponse to say the filter had been ignored — and every tag a caller applied to a subnet was
stored and invisible.
DescribeSnapshotsevaluated one of the fourteen filter names itsreference documents and read neither
Owner.NnorRestorableBy.N.Subnets
CreateSubnethonoursTagSpecification.Nscoped tosubnet, under the same two rulesevery other tag path enforces (reserved
aws:prefix, 50-tag limit); a refused requestcreates no subnet. Without it the filters below have nothing to find on a subnet the caller
just made, which is how CDK and Terraform set tags.
One shared
Subnetelement forCreateSubnetandDescribeSubnets, which is what AWSdocuments. They rendered different subsets before — create omitted
mapPublicIpOnLaunch, andneither carried tags, an ARN, an owner or
defaultForAz— so a caller reading the createresponse saw a different subnet from the one it could describe. A test asserts the two are
equal.
New members:
tagSet,subnetArn,ownerId,defaultForAz. The ARN and owner are whatsubnet-arnandowner-idcompare against, so rendering them is what lets a callerround-trip a value it read.
ec2SubnetARNis now the one spelling, shared by the filter, theresponse and
ec2_authz.go's launch resolver.Eleven filters plus AWS's four inline aliases (
availabilityZone,cidr,cidrBlock,defaultForAz), each answered beside its canonical name rather than normalized away — theyare distinct names on the wire, and folding them would leave the documented alias silently
inert.
cidr-blockis exact, per AWS's own sentence about it. The fourteen documented namessubstrate keeps no state for are accepted and inert; anything outside the twenty-five is
refused by ec2: three inconsistent unknown-filter-name behaviours, where real AWS refuses #687's spec, which this PR gives the operation.
tagSetis absent on an untagged subnet, not present-and-empty: both of AWS'sDescribeSubnetssamples omit it.DescribeSnapshots' present-but-emptytagSetis leftalone because its own page shows that shape — per-operation evidence, not a house rule.
Worth recording for the next person:
xml:"tagSet>item,omitempty"does not omit theparent element —
encoding/xmlemits<tagSet></tagSet>for a nil slice on a nested path.Omission needs a pointer-to-wrapper struct, verified empirically both ways (it decodes
identically through
tagSet>item). PR 6 (ec2: render CreateLaunchTemplate's warning/ValidationWarning element #693) needs the same shape for itswarningmember.Snapshots
description,encrypted,owner-id,snapshot-id,start-time,status,tag-key,tag:<key>,volume-id,volume-size. The other four(
owner-alias,progress,storage-tier,transfer-type) name members substrate does notrender, so there is nothing to compare against — accepted and inert.
Owner.NandRestorableBy.Nhonoured, with single-account semantics:selfand therequesting account's ID match everything; anything else,
amazonincluded, matchesnothing, because answering "snapshots owned by
amazon" with the account's own snapshotswould claim they were public.
ids.matchruns before the filter match on both operations, so a resource afilter excluded still counts as resolved — naming an existing ID and filtering it out is an
empty 200, not a
NotFound. That is the ruleec2IDFilter.unresolveddocuments, and thedifference between "not yet" and "never" to a consumer's wait loop.
Also in the same neighbourhood
The EC2 plugin's last two function-local
tagItemcopies (describeSnapshots,describeFleets) are deleted in favour of the package-levelec2TagItems, finishing what #686started. All four shapes matched, so nothing observable changes.
Fail-before proof
Recorded before the fix, with the anchor count asserted
== 1over the whole file, the filecopied to a
.origand restored in afinallywith byte-identity checked by sha256, andgofmt -w+go vetso a non-compiling mutant is BROKEN rather than a result. Full-packageruns, no
-runfilter.Snapshots — the pre-#685 handler body (
snapshot-idonly,Owner.N/RestorableBy.Nunread): 15 subtests plus 4 parent tests fail.
_StartTimeMatchesItsOwnSnapshotand_InertFiltersReturnEverythingcorrectly still pass — the first because its assertion ispositive, the second because inert is what the old code did to everything.
Subnets, two mutations:
describeSubnetsapplies no filters (_ = filters)createSubnetignoresTagSpecification.N(Tags: nil)tag*filter subtests,_TagSetIsAbsentWhenUntaggedand_TagsOnCreateAndAgreesWithDescribeRestore verified byte-identical after every mutation.
The first attempt at the second mutation printed
ANCHOR COUNT 2 - skippedrather thanmutating:
Tags: tags,appears in bothcreateSubnetandcreateVolume. Theanchor was widened to include the neighbouring
State:line rather than mutating blindly.Tests
Two new files, 40-plus subtests. The fixture worth explaining:
default-for-azandmap-public-ip-on-launchare only testable in both directions because a launch with noSubnetIdmints a default subnet with bothtrue—createDefaultSubnetis the sole writer ofeither.
_TagSetIsAbsentWhenUntaggedasserts on the raw body, since a decoder reports anabsent element and an empty one identically.
Verification
gofmt -l .,go build ./...,go vet ./...,golangci-lint run ./...(0 issues),make test(race),make coverage(82.2% total, emulator 82.8%),make docs-reference docs-reference-check docs-versions,npm --prefix docs run build,go vet -C test/e2e ./... && go test -C test/e2e ./...— all clean.Docs
docs/services.mdgains two subsections (a subnet's tags and filters; a snapshot's filters andaccount scopes), a
DescribeSubnetsrow and a correctedDescribeSnapshotsrow in #687'sper-operation Evaluated/Inert table, and three corrections the change makes necessary: five
operations now filter on tags rather than three,
DescribeSubnetsis the tenth operation therefusal rule covers, and #695's never-parse list drops from fourteen operations to thirteen
(verified by enumerating the dispatch arms, not by subtraction).