Skip to content

libimage: do not fail disk usage when an image is removed mid-walk - #1073

Merged
giuseppe merged 2 commits into
podman-container-tools:mainfrom
vtushar06:libimage-diskusage-removed-image
Sep 1, 2026
Merged

giuseppe merged 2 commits into
podman-container-tools:mainfrom
vtushar06:libimage-diskusage-removed-image

Conversation

@vtushar06

Copy link
Copy Markdown
Contributor

podman system df flakes in parallel CI runs when another test removes an image while df is walking the list:

# $ podman system df --format {{"\n"}}
# Error: Image f995a32fc412 exists in local storage but may be corrupted (remove the image to resolve the issue): reading image "f995a32fc412...": locating image with ID "f995a32fc412...": image not known
# [ rc=125 ]

(from https://github.com/podman-container-tools/podman/actions/runs/29565253194/job/87336101705, and again on 07-21)

DiskUsage lists the images once, then diskUsageForImage calls isCorrupted per image, so anything removed between the two steps kills the whole command. Same shape as the volume flavor that 246724fc6 fixed on the podman side, just on the image path.

Two small changes: isCorrupted wraps with %w instead of %v so the error keeps its type, and DiskUsage skips an image only on ErrImageUnknown. A genuinely corrupted image still fails - TestCorruptedLayers builds the missing-layer case and it passes unchanged, which I checked matters here because that error is ErrLayerUnknown, not ErrImageUnknown.

The new test fails on the old code (require.ErrorIs cannot see image not known through the %v wrap) and passes with the fix. Ran both tests on linux in a container.

@github-actions github-actions Bot added the common Related to "common" package label Aug 12, 2026
Comment thread common/libimage/image.go
Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
@vtushar06
vtushar06 force-pushed the libimage-diskusage-removed-image branch from dca9ffc to 4544bf0 Compare August 13, 2026 16:30
@vtushar06

Copy link
Copy Markdown
Contributor Author

@giuseppe I think this will be ready, just waiting for workflow to pass out

@vtushar06
vtushar06 requested a review from giuseppe August 20, 2026 02:47

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code change itself is fine, but since this is a race we cannot really that this like that. IMO we could drop the test as loing as all other pass that should be fine.

Comment thread common/libimage/corrupted_test.go Outdated
Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
@vtushar06

vtushar06 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@Luap99 yeahh right as the delete happens before DiskUsage lists the images, so it never walks that one and the assertion passes with or without the change. dropped the test, the two code commits are unchanged. let me know if everything is fine

@vtushar06
vtushar06 force-pushed the libimage-diskusage-removed-image branch from 4544bf0 to 0fe8ee9 Compare September 1, 2026 14:50

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Luap99

Luap99 commented Sep 1, 2026

Copy link
Copy Markdown
Member

@giuseppe PTAL again

@giuseppe giuseppe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@giuseppe
giuseppe merged commit dcb88d5 into podman-container-tools:main Sep 1, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants