Skip to content

snapshot: PrepareSnapshotImage's raw-image Cleanup never closes the source reader #999

Closed

Description

@scttfrdmn

Found by the new Windows CI job (#971): TestPrepareSnapshotImage_RawImagePassthrough failed on windows-latest because t.TempDir cleanup could not delete disk.raw ("being used by another process").

For a raw-image --from, PrepareSnapshotImage returns Cleanup: func() {}, and the only caller (cmd/snapshot.go) calls just Cleanup, never Reader.Close. So the opened local file (or S3 GetObject body) is never closed. On Linux this is a silent fd/connection leak until exit; on Windows the open handle also keeps the file locked. The tar/dir paths already close their image in Cleanup.

Fix: make the raw path's Cleanup close the reader, as its doc comment ("Cleanup removes any temp artifacts; always call it when done") implies.

Activity

  1. scttfrdmn commented on Oct 19, 2026

    @scttfrdmn
    ContributorAuthor

    Fixed in be7112d (#973, "Fixes #999"). pkg/aws/snapshot_image.go:90-93 on main: the raw-image path's Cleanup now closes the reader (Cleanup: func() { _ = rc.Close() }); CHANGELOG entry under (#999).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions