Skip to content

podstorage: Check image existence using image IDs - #2693

Merged
gursewak1997 merged 2 commits into
bootc-dev:mainfrom
Johan-Liebert1:fix-2640
Nov 30, 2026
Merged

gursewak1997 merged 2 commits into
bootc-dev:mainfrom
Johan-Liebert1:fix-2640

Conversation

@Johan-Liebert1

Copy link
Copy Markdown
Member

Ran into an issue where I'd specified, in the LBI file, the name of an images as Image=nginx:1.31.9-alpine-slim. The pruning function gathered a list of all present images locally and ended up with docker/library/nginx:1.31.9-alpine-slim which did not match the name I had in the .image file and the image ended up being pruned.

Fix this by gathering image IDs for all bound images and only prune the image if we can't find it by name and by ID. We still have to search by name as we can't be sure if the image which provisioned the system is present on the system or not.

Fixes: #2640

tmt: Add test for #2640

@Johan-Liebert1
Johan-Liebert1 requested review from cgwalters and a balanced review from Copilot November 25, 2026 03:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@bootc-bot
bootc-bot Bot requested a review from gursewak1997 November 25, 2026 03:40
@Johan-Liebert1
Johan-Liebert1 force-pushed the fix-2640 branch 2 times, most recently from 5bc551d to c87751c Compare November 26, 2026 03:40
}
// The bound image might've been skipped on installation
// So, don't throw an error if we fail to find it
Err(e) => {

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.

If inspect_image() fails, we continue without protecting this bound image. bound_roots are only matched by ID below, not by name, so an inspect failure can make an existing required image eligible for removal.
Could we fail/skip the prune on operational inspection errors, while still allowing a genuinely absent bound image?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated

Ran into an issue where I'd specified, in the LBI file, the name of an
images as `Image=nginx:1.31.9-alpine-slim`. The pruning function
gathered a list of all present images locally and ended up with
`docker/library/nginx:1.31.9-alpine-slim` which did not match the name I
had in the `.image` file and the image ended up being pruned.

Fix this by gathering image IDs for all bound images and only prune the
image if we can't find it by name and by ID. We still have to search by
name as we can't be sure if the image which provisioned the system is
present on the system or not.

Fixes: bootc-dev#2640

tmt: Add test for bootc-dev#2640

Signed-off-by: Pragyan Poudyal <[email protected]>
On an inspect failure, first try to recover the ID from the image list we
already fetched by matching on name, so the image stays protected without
aborting the whole prune. If no name matches, use a strict existence
check to distinguish a genuinely absent bound image  from one that is
present but unresolvable, and fail the prune in the latter case rather
than risk removing a required image

Add exists_strict(), which reads `podman image exists` exit codes - 0
present, 1 absent, other operational error - so a transient failure is no
longer treated as an absence of an image

Signed-off-by: Pragyan Poudyal <[email protected]>
@gursewak1997
gursewak1997 merged commit 1c618ce into bootc-dev:main Nov 30, 2026
96 of 99 checks passed
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.

Bound images referenced by tag@digest are pruned right after being pulled

3 participants