Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system df: fix image-size calculations #16211

Merged
merged 1 commit into from
Oct 19, 2022

Conversation

vrothberg
Copy link
Member

Fix two bugs in system df:

  1. The total size was calculated incorrectly as it was creating the sum of all image sizes but did not consider that a) the same image may be listed more than once (i.e., for each repo-tag pair), and that b) images share layers.

    The total size is now calculated directly in libimage by taking multi-layer use into account.

  2. The reclaimable size was calculated incorrectly. This number indicates which data we can actually remove which means the total size minus what containers use (i.e., the "unique" size of the image in use by containers).

Fixes: #16135
Signed-off-by: Valentin Rothberg [email protected]

Does this PR introduce a user-facing change?

Fix a bug where `podman system df` reported wrong image sizes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 18, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vrothberg

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 Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 18, 2022
@vrothberg
Copy link
Member Author

The failures seem to be triggered by containers/storage@main

Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

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

Could you run your new tests against main? They pass for me, which means you're not actually testing your changes.

test/system/320-system-df.bats Outdated Show resolved Hide resolved
test/system/320-system-df.bats Outdated Show resolved Hide resolved
@vrothberg
Copy link
Member Author

The failures seem to be triggered by containers/storage@main

For now I forced back the previous c/storage version via a replace. @mtrmac @rhatdan PTAL

@vrothberg
Copy link
Member Author

Easy reproducer among others:

$ go get github.com/containers/storage@main
$ make vendor && make podman
$ ./test/apiv2/test-apiv2 images

@edsantiago
Copy link
Member

Out of curiosity, do you know when this broke? Last night's treadmill job passed. Could the breakage have happened late last night? Or is the treadmill broken?

@vrothberg
Copy link
Member Author

Out of curiosity, do you know when this broke? Last night's treadmill job passed. Could the breakage have happened late last night? Or is the treadmill broken?

No idea, sorry. c/storage had a lot of traffic recently.

@mheon
Copy link
Member

mheon commented Oct 18, 2022

Code LGTM

Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

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

Tests are still broken, in the sense that they pass on main. You are not testing anything new. Can you please find a way to write tests that break on main and pass with this PR?

@vrothberg
Copy link
Member Author

Tests are still broken, in the sense that they pass on main. You are not testing anything new. Can you please find a way to write tests that break on main and pass with this PR?

Thanks for checking, Ed! Will do 👍

Also need to update the apiv2 tests:

[+0165s] not ok 993 [45-system] GET libpod/system/df : output
[+0165s] #  expected: {"Images":[],"Containers":[],"Volumes":[]}
[+0165s] #    actual: {"ImagesSize":0,"Images":[],"Containers":[],"Volumes":[]}

Fix two bugs in `system df`:

1.  The total size was calculated incorrectly as it was creating the sum
    of all image sizes but did not consider that a) the same image may
    be listed more than once (i.e., for each repo-tag pair), and that
    b) images share layers.

    The total size is now calculated directly in `libimage` by taking
    multi-layer use into account.

2.  The reclaimable size was calculated incorrectly.  This number
    indicates which data we can actually remove which means the total
    size minus what containers use (i.e., the "unique" size of the image
    in use by containers).

NOTE: The c/storage version is pinned back to the previous commit as it
      is buggy.  c/common already requires the buggy version, so use a
      `replace` to force/pin.

Fixes: containers#16135
Signed-off-by: Valentin Rothberg <[email protected]>
@vrothberg
Copy link
Member Author

@edsantiago can you take another look at the tests?

@edsantiago
Copy link
Member

ARGH! Sorry; left tests running this morning, moved on to something else. New test looks great, and fails (as it should) on main. Thank you!
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 19, 2022
@openshift-merge-robot openshift-merge-robot merged commit 5af1c42 into containers:main Oct 19, 2022
@vrothberg vrothberg deleted the fix-16135 branch October 19, 2022 14:46
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman system df does not seem to report actual disk usage
5 participants