Repository navigation
fix(ec2): CreateVolume invents neither a size nor a zone (#712) - #723
Merged
Merged
Conversation
AWS puts two combination rules on CreateVolume and marks every member involved Required: No, because each requirement is on a *pair*: "You must specify either a snapshot ID or a volume size" and, said once on each member, "Either AvailabilityZone or AvailabilityZoneId must be specified, but not both." Substrate read neither. A request naming no size got a silent 8 GiB volume, one naming Size=-1 or Size=eight got the same, and one naming no zone got <region>a — each with HTTP 200 and a volume ID, so the volume was real, at a size and in a zone the caller never asked for, and the first symptom was an attach failing later with nothing to point at. AvailabilityZoneId is read for the first time; it resolves through the same derivation DescribeAvailabilityZones renders from. That made the zone-ID shape load-bearing on the request side and exposed the derivation's own bug: it produced ue11-az1 for us-east-1 where AWS publishes use1-az1. Both refusal codes are substrate's reading — CreateVolume's Errors section is empty — from InvalidParameterCombination's gloss, the only one naming a missing parameter in an either/or. Closes #712
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 #712
What AWS documents, and what #712 got wrong
CreateVolumeputs two combination rules on its parameters and marks every member involvedRequired: No, because each requirement is on a pair:Size— "You must specify either a snapshot ID or a volume size."AvailabilityZone/AvailabilityZoneId— said once on each member: "EitherAvailabilityZoneorAvailabilityZoneIdmust be specified, but not both."#712's premise is corrected in passing: it quotes AWS as documenting "Size is required unless SnapshotId is specified" and
AvailabilityZoneas required. Neither sentence exists. The rules are the combination ones above, which is why both members readRequired: No.What substrate did
It read neither rule, and answered HTTP 200 in every broken case:
Size, noSnapshotIdInvalidParameterCombination, 400Size=-1,Size=eight,Size=8.5InvalidParameterValue, 400, quoting the value<region>aInvalidParameterCombination, 400InvalidParameterCombination, 400AvailabilityZoneIdaloneaThe size parse was
if n, err := strconv.Atoi(s); err == nil && n > 0with noelse— a discarded error and a discarded out-of-range value. Each of these reported success, so the volume was real, at a size and in a zone the caller never asked for, and the first visible symptom was an attach failing later with nothing to point at. All three refusals land before the state write;TestEC2_CreateVolume_RefusalWritesNothingpins that five refused calls leaveDescribeVolumesempty.AvailabilityZoneId, and the zone-ID bug it exposedThe ID resolves through the same derivation
DescribeAvailabilityZonesrenders from, so a zone ID read out of one operation is one the other accepts — pinned by round-tripping all three zones.Making a zone ID an input for the first time exposed the derivation: it produced
ue11-az1forus-east-1— wrong prefix, doubled digit — where AWS publishesuse1-az1, and the code's own comment claimeduse1. Nothing caught it because zone IDs were only ever emitted, and a test that read one back and filtered on it was self-consistent whatever the string said. A consumer fixture carrying the realuse1-az1would have been refused.AWS's table refutes AWS's own summarising sentence ("the first three letters of the Region code, followed by the number at the end"): that rule gives
aps2forap-southeast-2, and the table saysapse2. The real shape is the first segment verbatim, one letter per compass word, then the trailing number.TestEC2_ZoneIDPrefixMatchesAWSPublishedTablepins 18 rows copied from the table, withap-southeast-2andap-northeast-1as the rows that settle it.Two deliberate asymmetries, documented rather than left to be discovered:
InvalidParameterValue, not the combination code — the pair is well-formed, the value is not.Provenance
Both refusal codes are substrate's reading.
CreateVolume's Errors section is empty — it publishes no operation-specific error at all — so #712's acceptance criterion "verify the code against the reference" cannot be met as written.InvalidParameterCombination's EC2 client-error gloss is the only candidate whose shape fits: "The request includes an incorrect combination of parameters, or a missing parameter."The zone-ID prefix comes from AWS's published table, chosen over AWS's prose describing it. AWS also states "we independently map Availability Zones to codes for each AWS account", so the real name→ID pairing is per-account; substrate always maps zone
ato-az1, and the docs say plainly not to use substrate to verify that code treats the mapping as account-specific.Also fixed: a wall-clock-dependent test
DescribeSpotPriceHistoryrenders its timestamp from the time controller at scale 1.0, so the RFC3339 value changes at every second boundary. #695's timestamp subtest read the value out of one response and filtered on it in the next, failing whenever a second elapsed between them — about one run in sixty, onmain. It runs against a frozen clock now (scale zero; reachable only in-process, sincePOST /v1/control/scalerefuses a non-positive scale).Out of scope, stated in the docs
AWS's per-volume-type size ranges (
gp21–16384,io14–16384,st1/sc1125–16384,standard1–1024) are still unenforced, andIops/Throughputkeep their existing tolerance for an unparseable value —Sizediffers because its absence differs: a volume must have a size, while omittingIopsis the ordinary case for the five types that do not take one. The launch path keepsec2DefaultVolumeSizeGiB, where a mapping omitting a size is legal; its doc comment now says it no longer backsCreateVolume.Verification
Fail-before established empirically in a throwaway worktree at
6f0f579: all five newCreateVolumetests failed, 22 subtests — and the failing subtest names (ue11-az2,ue11-az3) are what exposed the zone-ID bug.