Repository navigation
feat(ec2): a volume can be tagged, reports its tags, and is filterable by them (#670) - #681
Merged
Merged
Conversation
…e by them (#670) A volume was the one taggable EC2 resource with no working tagging path, and every call on it answered success: CreateVolume accepted TagSpecification.N and stored nothing, CreateTags on a vol- ID answered <return>true</return> and wrote nothing, DescribeVolumes rendered no tagSet and matched no tag filter, and EC2Volume.Tags existed with nothing ever writing to it. Four paths are now real — CreateVolume, RunInstances' volume scope, a launch template's volume scope, and CreateTags/DeleteTags on a vol- ID — with both tag rules applied on each, checked before the launch loop so a refusal leaves no instance behind. describeVolumes' hand-rolled nine-set filter loop is replaced by the shared extractEC2Filters walk plus a match function, which is what makes tag:<key> expressible, and CreateVolume stopped discarding Iops and Throughput. The template's volume scope goes in a new VolumeTagSpecifications field rather than widening the persisted instance-scoped one, which would have silently untagged every template already in an event log.
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 #670.
A volume was the one taggable EC2 resource with no working tagging path at all, and
every call on it answered success:
CreateVolumeacceptedTagSpecification.Nand stored nothing.CreateTagson avol-ID answered<return>true</return>and wrote nothing —the issue's "may already work" premise, traced end to end and false.
DescribeVolumesrendered notagSetand supported no tag filter.EC2Volume.Tagsexisted, with nothing ever writing to it.So an IaC consumer's tag-everything convention appeared to hold and nothing could
observe that it had not — the same store-and-hide shape #471 closed for a launch
template's tags.
What changed
Four paths, all now real:
CreateVolumevolume-scopedTagSpecification.N, echoes atagSetRunInstancesvolume-scoped tags to every volume the launch makes, synthesized root includedCreateTags/DeleteTagsvol-ID like any other taggable IDBoth tag rules apply on all four — reserved
aws:prefix and the 50-tag limit, sinceAWS documents no volume-specific constraint. On a launch the check runs before the
launch loop: a volume is written after its own instance, so a refusal inside the loop
would leave instance 1 of a
MaxCount=2launch behind.DescribeVolumesgainstag:<key>andtag-key— exactly the two tag filters AWSdocuments for the operation, out of 20; there is no
tag-value. Its hand-rolledFilter.Nloop, whose ninemap[string]boolsets could not express a filter whose keyis part of its name, is replaced by the shared
extractEC2Filterswalk plus a matchfunction, per the issue's "rather than a second hand-rolled implementation".
CreateVolumealso stopped discardingIopsandThroughput, whichEC2Volumestoredand
DescribeVolumesrendered — so a provisioned volume created that way read back as anunprovisioned one, while the same values through a launch mapping did not.
The one risky piece, and the mitigation
The template's volume scope is a new
VolumeTagSpecificationsfield, not a widenedTagSpecifications. Adding aResourceTypediscriminator to the existing persistedfield would unmarshal every template already in an event log without error — into an
element with an empty resource type and no tags — so every stored template would
silently start launching untagged instances. That is deterministic replay broken by a
change that compiles.
EC2LaunchTemplateData.NetworkInterfacesalready uses this splitfor the same reason.
Fail-before proof
go test ./emulator/ -run 'TestEC2_(CreateVolume|CreateTags_OnVolume|DescribeVolumes|RunInstances_Volume|LaunchTemplate_Volume)', onmainat e111039 with the new test file added and no other change:Illustrative: the reserved-key and over-long-key
CreateVolumerows returned 200 andleft
vol-52fb17a02eac01a2/vol-55e237ecad5b242abehind;_IopsAndThroughputgot 0for both;
_VolumeTagsAreFilterablegotmap[string]string{}.TestEC2_DescribeVolumes_ExistingFiltersStillWorkpassed before and after, which iswhat a regression guard for the filter-loop replacement is for.
One existing assertion inverted
TestEC2_RunInstances_ReservedTagRejectionCreatesNothing's last case asserted the olddeliberate limit — a volume-scoped reserved key did not fail an instance launch,
because the scope was parsed nowhere and an unapplied specification was an unchecked one.
It now fails the launch, and the row asserts the refusal leaves no instance behind.
Provenance
tagSetelement carries noomitemptybecause AWS's secondCreateVolumeexamplerenders
<tagSet/>for an untagged volume, and an SDK tells present-but-empty ("notags") from omitted ("unknown").
tag:<key>filter with no value matches nothing — substrate's answer where AWSdocuments none (
Using_Filteringsays only that a filter value cannot be null, andoffers
tag-keyfor the any-value question). This followsDescribeInstances;describeImages, which treats it astag-key, is deliberately left alone and filed asa follow-up rather than changed in this PR.
behavior every other EC2 filter site has" is corrected: three behaviours exist in the
package — drop (volumes, snapshots), match-nothing (
ec2InstanceMatchesFilter), andrefuse (
describeInstanceTypeOfferings, which is what real EC2 does).Compatibility
CreateVolumeandDescribeVolumesresponses gaintagSet,iopsandthroughput— abyte-exact response assertion will see them. A
RunInstancesorCreateLaunchTemplatenaming a reserved key or more than 50 tags in a
volume-scopedTagSpecificationnowfails where it previously succeeded with those tags dropped.
Verification
The SDK-tier journey is
TestJourney_EC2VolumeTags:CreateVolumewith tags andprovisioned performance, a launch tagging both scopes,
tag:Envalone and AND-combinedwith
attachment.instance-id, aCreateTags/DeleteTagsround trip on the volume, anda reserved-key refusal that leaves no instance behind.