Repository navigation
fix(ec2): a launch-declared data volume is preserved on termination (#675) - #678
Merged
Merged
Conversation
…675) Two current AWS pages disagree about DeleteOnTermination's default for a volume a launch creates. block-device-mapping-concepts gives the split — true for the root, false for attached volumes — while preserving-volumes-on-termination's console-vs-CLI table lists a launch-created data volume as Delete. #666 followed the second and applied true to everything, and both the code comment and the docs presented that as simply AWS's documented behavior. The API reference documents no default at all, and both guide pages agree the real one comes from the AMI's own mapping, which substrate's AMIs do not carry. So the value is substrate's choice either way, and the non-destructive side of a genuine ambiguity wins: a volume wrongly preserved is correctable, one wrongly deleted is gone. The root still defaults to true, keyed off the resolved device name so a mapping naming no device is treated as the root it becomes. AttachVolume is unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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 #675.
The conflict
Two current AWS pages disagree about
DeleteOnTermination's default for a volume a launch creates:block-device-mapping-conceptsstates the default is "truefor the root volume andfalsefor attached volumes".preserving-volumes-on-terminationcarries a console-vs-CLI table listing a launch-created data volume as Delete when the launch came through the CLI.#666 followed the second page and applied
trueto every launch-created volume, root and data alike. The code comment argued it well — "its termination table splits on how the volume was attached, not on what it is … and substrate has no console" — but presented the answer as simply AWS's documented behavior, with no note that another current page says the opposite.Why the split wins
The API reference itself documents no default for
EbsBlockDevice.DeleteOnTermination, and its only pointer on the subject is a link that no longer resolves to the content it cites. Both guide pages agree the real launch default comes from the AMI's own block device mapping — which substrate's AMIs do not carry. So the value is substrate's choice either way, and given a genuine ambiguity the non-destructive side is the one a test emulator should take: a volume wrongly preserved is visible and correctable, while one wrongly deleted is gone and the caller learns of it by its absence rather than by an error. A consumer reading the page that describes the mapping shape they are writing would otherwise find substrate wrong rather than opinionated.What changed
ec2VolumeFromMappingdefaultsDeleteOnTerminationtoec2IsRootDevice(device)rather than unconditionaltrue. It keys off the resolved device name, so a mapping naming no device — which lands on/dev/sda1— is treated as the root it became rather than as a data volume. An explicit value still wins.AttachVolume'sfalseis untouched and unaffected; both pages agree about a volume attached after launch, and its comment needed no root-device special case.ec2_block_devices.go'sec2LaunchVolumesFor,EC2VolumeAttachment.DeleteOnTermination's field doc, anddocs/services.md. The docs paragraph names both pages and states which wins and why, per the house provenance rule.Fail-before proof
The contested default had no HTTP-tier coverage at all — every existing case either names a root device or sets the value explicitly.
TestEC2_BlockDeviceMapping_DataVolumeDefaultPreserveswas written first and run againstmain:The second failure is the one that matters: the volume was not merely mislabelled, it was destroyed.
Tests
TestEC2_BlockDeviceMapping_DataVolumeDefaultPreserves(HTTP) — root and data volume in one launch, neither naming the value, asserting the two differ and that termination honors the difference. The rendered flag and what termination does have to agree.TestJourney_EC2LaunchDataVolumeSurvivesTermination(SDK) — the tier the change is consumer-visible at.TestEC2LaunchVolumesrows that pinnedtruefor a data volume, and rewrote the case comment that argued for it. (The plan for this release recorded the default as untested; it was in fact pinned in three unit rows, which is where the fail-before evidence for the unit tier came from.)#675note the two assertions the issue names —journey_ec2_block_devices_test.goandec2_block_devices_http_test.go's repro — both of which are on a root device and so keeptrue.Verification
gofmt,go build,go vet,golangci-lint runclean;make test(race) green;go test -C test/e2e ./...green;go run ./cmd/gen-service-reference -checkandscripts/check-doc-versions.shclean.Compatibility
A data volume that a launch created and
TerminateInstancesdeleted in v0.103.0/v0.104.0 now survives asavailablewith no attachment, andDescribeVolumesreportsdeleteOnTermination=falseon its attachment where it previously reportedtrue. A mapping namingDeleteOnTerminationexplicitly is unaffected, as is every root-device mapping and every volume attached after launch.