Skip to content

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Mar 7, 2025

The old implementation only counted full images when sharing content between them. That is wrong, the store is layer based. We can have two images with no parent image that shares layers.

As such get rid of the image tree that only is able to walk child/parent images. Instead we actually walk all layers now and correctly notice when they are shared.

To this this correctly, first convert all layers to map so we can look them up by ID. And add missing size information if needed. Then we walk all images layers and count how often each layers is used. Then walk again but this time we know if the layer size must be shared or not so we can actually acount things correctly.

Fixes: containers/podman#24452
Fixes: https://issues.redhat.com/browse/RHEL-29641

Copy link
Contributor

openshift-ci bot commented Mar 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Mar 7, 2025
@Luap99
Copy link
Member Author

Luap99 commented Mar 7, 2025

cc @mtrmac

I will make a PR against podman to see if any tests blow up with it and also add a test based on the actual reproducer that was given.

@Luap99
Copy link
Member Author

Luap99 commented Mar 7, 2025

podman side containers/podman#25506

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks!

This looks very clearly to be counting the right thing, in particular that layerTree’s parent/child heuristics really don’t matter here.

// does try to lookup this map as well but also falls back to reading
// the full big data files into memory for no apparent reason.
// Can we trust that the map always has the data we care about?
// Is there ever a case where this matters if the map does not have all the data?
Copy link
Contributor

Choose a reason for hiding this comment

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

There was a time where BigDataSizes did not exist.

… for about 3 months in 2016. Nominally, the code does not have any mechanism to refuse working on such old stores.

I don’t have a strong opinion on caring about this.

Copy link
Member Author

Choose a reason for hiding this comment

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

ack thanks, I guess we don't worry about it then.

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

LGTM (assuming the Podman tests don’t reveal any surprises).

The old implementation only counted full images when sharing content
between them. That is wrong, the store is layer based. We can have two
images with no parent image that shares layers.

As such get rid of the image tree that only is able to walk child/parent
images. Instead we actually walk all layers now and correctly notice
when they are shared.

To this this correctly, first convert all layers to map so we can look
them up by ID. And add missing size information if needed. Then we walk
all images layers and count how often each layers is used. Then walk
again but this time we know if the layer size must be shared or not so
we can actually acount things correctly.

Fixes: containers/podman#24452
Fixes: https://issues.redhat.com/browse/RHEL-29641

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

/lgtm

Failures in containers/podman#25506 seem to be the usual registry flakes only.

@openshift-ci openshift-ci bot added the lgtm label Mar 10, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 09fe0ef into containers:main Mar 10, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command podman system df returns a negative reclaimable size of images
2 participants