Repository navigation
feat: attach EBS data volume from a snapshot at launch (#144) - #145
Merged
Merged
Conversation
Adds `spawn launch --attach-volume snap-xxx:/mount/point[:ro|:rw]` (repeatable) so large reference data lives in a re-snapshottable EBS volume on a stock AMI instead of being baked into a custom AMI. - pkg/aws: new AttachVolumeSpec + LaunchConfig.AttachVolumes; buildBlockDevices appends one snapshot-backed BDM per spec on /dev/sdf, /dev/sdg, … with DeleteOnTermination=true (so the per-task copy dies with the instance) and inheriting EBS encryption/KMS. Exported AttachDeviceName keeps the CLI and block-device side on the same device-name scheme. - pkg/userdata: storage user-data gains an attached-EBS branch — NVMe-aware device resolution (the requested /dev/sdf is remapped on Nitro), ro/rw mount, fstab with nofail, and never mkfs (snapshot already has a filesystem). - cmd/launch: --attach-volume flag, parseAttachVolumes (validates snap- prefix, absolute mount, ro/rw mode), wired into both the single-instance and job-array storage user-data paths. Unblocks nf-spawn#45 (per-process ext.volumes).
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 #144. The spawn-side primitive that nf-spawn#45 depends on.
What
spawn launch --attach-volume snap-xxx:/mount/point[:ro|:rw](repeatable) attaches an additional EBS data volume created from a snapshot, mounted at the given path — read-only by default (the common case for shared reference data). So large reference data (the motivating case: a ~16 GB Kraken2 DB for nf-core/taxprofiler) lives in a re-snapshottable volume on a stock AMI instead of being baked into a custom AMI.How
pkg/aws— newAttachVolumeSpec+LaunchConfig.AttachVolumes.buildBlockDevicesappends one snapshot-backed block-device mapping per spec on/dev/sdf,/dev/sdg, … withDeleteOnTermination=true(the per-task copy dies with the ephemeral instance — lifecycle invariant; the snapshot persists) and inheriting EBS encryption/KMS. ExportedAttachDeviceName(i)keeps the CLI and BDM sides on the same device-name scheme.pkg/userdata— storage user-data gains an attached-EBS branch:/dev/sdfis remapped to an NVMe device in nondeterministic order.spawn_resolve_devwaits for AL2023'sec2-utils/dev/sdfsymlink and falls back to scanningebsnvme-id, so we mount the right device, not a guessed path.nofail(a missing data volume never wedges boot), and nevermkfs— a snapshot-backed volume already has a filesystem.cmd/launch—--attach-volumeflag;parseAttachVolumesvalidates thesnap-prefix, absolute mount path, andro/rwmode; wired into both the single-instance and job-array storage user-data paths.Tests
pkg/aws: attached volumes append snapshot BDMs on distinct device names withDeleteOnTermination, size override vs snapshot size, encryption/KMS inheritance;AttachDeviceNamemapping.pkg/userdata: ro mount + device resolution +nofail+ no reformat; rw variant.cmd:parseAttachVolumeshappy paths + rejects (no mount / relative path / non-snapshot id / bad mode / too many parts);attachedVolumesUserDatadevice-name mapping.make checkgreen.Cost / lifecycle
The attached volume is created from the snapshot at launch with
DeleteOnTermination=true, so it's cleaned up with the instance — no leaked volumes. A read-only reference volume fanned out across many task instances is many EBS volumes from one snapshot; that's the expected, intended trade against per-task S3 download / oversized root volumes.Follow-up
Not in this PR: a live paid validation (launch a stock AL2023 arm64 with
--attach-volume <kraken2-snap>:/opt/databases/kraken2:ro, confirm the DB is present read-only at the mount, terminate, leak-check the auto-created volume is gone). Will run that against the taxprofiler demo with the filer once nf-spawn#45 lands on top.