Repository navigation
fix(aws): derive root block device from AMI, not hardcoded /dev/xvda (#284) - #346
Merged
Merged
Conversation
…284) buildBlockDevices hardcoded the root DeviceName to /dev/xvda. For AMIs whose registered root device is /dev/sda1 (Ubuntu, Rocky, Debian, many marketplace images) the root mapping didn't match the AMI, so RootVolumeSizeGiB + EBS encryption/DeleteOnTermination landed on a non-root device — EC2 silently kept the AMI's default (8-20 GB) root and could attach a stray volume. A caller asking for a 200 GB Ubuntu root got the default with no error. Fix: derive the root device name from the AMI's RootDeviceName. Refactored rootVolumeSizeFromAMI → rootDeviceInfoFromAMI, which returns (rootName, minGiB) from the SAME DescribeImages call Launch already made for the #25 snapshot-minimum (no extra round-trip). buildBlockDevices now takes rootDeviceName and uses it for the root mapping, falling back to /dev/xvda when empty. #25 snapshot-floor behavior is unchanged. Unblocks Prism (github.com/scttfrdmn/prism), which kept its launch path off spawn specifically because of this hardcode (its templates are Ubuntu/Rocky). Verified: go build ./..., go vet, gofmt clean; new TestBuildBlockDevices subtests (/dev/sda1 carries the override; empty→/dev/xvda fallback) + all existing block-device/root-size tests pass; full pkg/aws suite green.
scttfrdmn
force-pushed
the
spawn/284-root-device
branch
from
July 12, 2026 18:47
794784d to
6d93f10
Compare
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 #284. Real bug fix — root-volume overrides silently no-op'd on
/dev/sda1AMIs.Problem
buildBlockDeviceshardcoded the rootDeviceNameto/dev/xvda. AWS AMIs register their root device inImage.RootDeviceName— Amazon Linux uses/dev/xvda, but Ubuntu, Rocky, Debian, and many marketplace AMIs use/dev/sda1. When they differ, the root mapping spawn built didn't match the AMI, soRootVolumeSizeGiB(and EBS encryption / DeleteOnTermination) landed on a non-root device: EC2 kept the AMI's default (often 8–20 GB) root and could attach a stray/dev/xvdavolume — no error. A caller asking for a 200 GB Ubuntu root got the default.Fix
Derive the root device name from the AMI. Refactored
rootVolumeSizeFromAMI→rootDeviceInfoFromAMI, which returns(rootName, minGiB)from the sameDescribeImagescallLaunchalready made for the #25 snapshot-minimum — no extra API round-trip.buildBlockDevicesnow takesrootDeviceNameand uses it for the root mapping, falling back to/dev/xvdaonly when the lookup fails/empty. The #25 snapshot-floor behavior is unchanged.Verification
go build ./...,go vet ./pkg/aws,gofmtclean.TestBuildBlockDevicessubtests:/dev/sda1root carries the size override; empty root name falls back to/dev/xvda. All existing block-device +TestRootVolumeSizeFromMappingstests updated to the new signature and pass; fullpkg/awssuite green (excl. pre-existingTestCatalogValid/ feat(plugin): permissions declaration block (#388) #392).Why it matters
Unblocks Prism (
github.com/scttfrdmn/prism), which migrated its EC2 lifecycle ontospawn.Clientbut kept launch on its own path specifically because of this hardcode (its default templates are Ubuntu/Rocky →/dev/sda1). Matching the AMI's root device lets Prism route launch through spawn too.