Skip to content

feat(ec2): RegisterImage with explicit BDM snapshot-id for shared snapshots (#328)#329

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/328-register-image-shared-snapshot
Jun 10, 2026
Merged

feat(ec2): RegisterImage with explicit BDM snapshot-id for shared snapshots (#328)#329
scttfrdmn merged 1 commit into
mainfrom
feat/328-register-image-shared-snapshot

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Follow-up to #322. Enables the "retain a snapshot shared by multiple AMIs" path in spore.host/spawn's DeleteAMI to be tested end-to-end.

Diagnosis

The issue reported the block-device-mapping.snapshot-id filter returning only one AMI for a shared snapshot. Reproduced empirically — and the filter was already correct (it returns all matching AMIs, no early break). The real gap: two CreateImage calls from the same instance produce different snapshots (each gets a fresh snap-id, matching real AWS), so a shared snapshot never existed to be found.

Fix

Add RegisterImage honoring BlockDeviceMapping.N.Ebs.SnapshotId, so a caller can register an AMI pointing at an existing snapshot — the AWS-faithful way to share a snapshot across AMIs (vs. CreateImage, which always materializes a new one). DescribeImages filtered by that snapshot then returns every referencing AMI.

Verification

TestEC2_RegisterImage_SharedSnapshot: CreateImage A → snap-X; RegisterImage B on snap-X; filter by snap-X returns both A and B. make test (race) + make lint clean. Param shapes (BlockDeviceMapping.N.Ebs.SnapshotId, RegisterImageResponse) verified against the EC2 API reference.

Closes #328

…pshots (#328)

Follow-up to #322. The block-device-mapping.snapshot-id filter already returned
ALL matching AMIs, but two CreateImage calls never shared a snapshot (each gets
a fresh snap-id, as in real AWS), so a shared snapshot couldn't exist to test the
'retain shared snapshot' path.

Adds RegisterImage honoring BlockDeviceMapping.N.Ebs.SnapshotId so a caller can
register an AMI pointing at an existing snapshot — the AWS-faithful way to share
a snapshot across AMIs. DescribeImages then returns every AMI referencing it.

Regression test TestEC2_RegisterImage_SharedSnapshot: CreateImage A -> snap-X,
RegisterImage B on snap-X, filter by snap-X returns both A and B.
make test (race) + lint clean.

Closes #328
@scttfrdmn scttfrdmn merged commit e2be9aa into main Jun 10, 2026
9 checks passed
@scttfrdmn scttfrdmn deleted the feat/328-register-image-shared-snapshot branch June 10, 2026 05:29
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/ec2_plugin.go 82.35% 3 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EC2: block-device-mapping.snapshot-id filter returns only one AMI when a snapshot is shared by multiple AMIs

1 participant