fix(launch): auto-detect minimum root volume size from AMI snapshot (#25) - #45
Merged
Conversation
) Launching from a custom AMI whose root snapshot is larger than spawn's default (20 GiB) failed with InvalidBlockDeviceMapping ('Volume of size 20GB is smaller than snapshot, expect size >= 80GB'), forcing users to pass --volume-size explicitly with a number they had to know out of band. Launch now queries the AMI's BlockDeviceMappings (rootVolumeSizeFromAMI) and floors the root volume at the snapshot minimum: the final size is max(chosen, amiMin). This fixes both the default-20 case and an explicit --volume-size that's too small. Best-effort: any DescribeImages error returns 0 and leaves the chosen size unchanged, so a launch never fails because the lookup didn't work. buildBlockDevices gains an amiMinGiB floor parameter; unit tests cover floor-raises-default, floor-beats-too-small-explicit, and larger-explicit-is-kept. Closes #25
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Split the BDM root-device selection out of rootVolumeSizeFromAMI (which needs a live EC2 client) into a pure rootVolumeSizeFromMappings, and cover the tricky bits: root-device match by name, largest-EBS fallback when the root name doesn't match, skipping non-EBS mappings, and the empty case.
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 #25.
Problem
Launching from a custom AMI whose root snapshot is larger than spawn's 20 GiB default fails:
Users had to pass
--volume-size 80with a number they had to discover out of band. (Also the root cause behind nf-spawn#21.)Fix
Launchnow queries the AMI'sBlockDeviceMappings(newrootVolumeSizeFromAMIhelper) and floors the root volume at the snapshot minimum — final size ismax(chosen, amiMin). This rescues:--volume-size), and--volume-sizethat's smaller than the snapshot.Best-effort: any
DescribeImageserror (AMI not found, no permission) returns 0 and leaves the chosen size unchanged — a launch never fails because the lookup didn't work. Root device is matched byRootDeviceName, falling back to the largest EBS mapping as a safe floor.Test
buildBlockDevicesgains anamiMinGiBfloor param; unit tests cover floor-raises-default, floor-beats-too-small-explicit, and larger-explicit-is-kept. Verified Tier 0 launch path unaffected (substrate's synthetic AMIs have no registered BDM, so the lookup returns 0 — no regression).Follow-ups
ext.volumeSizeworkaround becomes unnecessary (spawn does the right thing automatically).