Repository navigation
feat: spawn snapshot create --from accepts dir/tar/tar.gz (#147 Part B) - #150
Merged
Merged
Conversation
The fs-builder half of #147, kept instance-free. --from now accepts a directory or a .tar/.tar.gz/.tgz in addition to a raw image: the contents are converted to an ext4 filesystem image in-process via hcsshim's tar2ext4 (pure Go — no mkfs, no builder instance) and streamed into the EBS-direct snapshot. Building the filesystem on the host (vs a transient EC2 bake box) was the whole point of the EBS-direct path — an instance would have defeated it. tar2ext4 is stdlib-only and cross-platform, so this works the same from macOS, Linux, and Windows. The ext4 image is sized to the data and capped at --size; a raw image still streams verbatim. - pkg/aws/snapshot_image.go: classifySnapshotSource, tarDirectory (dir→tar), transparent gunzip, PrepareSnapshotImage (→ ext4 image reader + cleanup). - cmd/snapshot.go: wire PrepareSnapshotImage; updated help/flags. - Tests: classify, gzip-name, tar-from-dir, and end-to-end dir/tar.gz → valid ext4 (superblock magic) + raw passthrough.
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.
Part B fs-builder for #147 — the ergonomic front door you asked for: pass a directory, tar, or tar.gz and go, kept fully instance-free.
The decision
Building a populated Linux filesystem normally needs
mkfs(Linux-only, not pure-Go-able). A first instinct was a transient builder EC2 instance — but as you put it, if you have to launch an instance, you don't need the EBS-direct path at all. So the only version worth building keeps it instance-free.go-diskfs's ext4 writer is broken (itsMkdirerrors out), but Microsoft'shcsshim/ext4/tar2ext4does exactly tar→ext4 in pure Go — stdlib only, no cgo, no GOOS constraint. Verified it builds a valid, mountable ext4 image on macOS (ext4 superblock magic0x53EFpresent). So:What
spawn snapshot create --fromnow accepts:.tar/.tar.gz/.tgz(local ors3://) → (gunzipped and) converted to ext4All three requirements met at once: dir/tar ergonomics, instance-free, runs from macOS/Linux/Windows (pure Go). The ext4 fs is built compactly (sized to content, capped at
--size) and streamed into the EBS-direct snapshot via the same Part A pipeline.How
pkg/aws/snapshot_image.go:classifySnapshotSource(dir / tar / raw),tarDirectory(walks a dir → tar stream, forward-slash paths, symlinks), transparent gunzip,PrepareSnapshotImage(returns an ext4-imageio.ReadCloser+Cleanupfor the temp image; raw passes through untouched).cmd/snapshot.go: wired toPrepareSnapshotImage; help/flags updated.Tests
classifySnapshotSource(incl. s3 by-extension + case-insensitive),isGzipName,tarDirectoryround-trip, and end-to-endPrepareSnapshotImagefor directory → valid ext4, tar.gz → valid ext4 (assert the superblock magic), and raw passthrough (bytes unaltered).make checkgreen; Tier 0 coverage gate already classifiessnapshot.Still deferred
--attach-volume snap-xxx:/mount:ro) #144's live test.