Skip to content

Honor label filters for volume prune when all is set#29038

Merged
Honny1 merged 1 commit into
podman-container-tools:mainfrom
shuaiyuanxx:fix-volume-prune-all-label-filters
Jun 29, 2026
Merged

Honor label filters for volume prune when all is set#29038
Honny1 merged 1 commit into
podman-container-tools:mainfrom
shuaiyuanxx:fix-volume-prune-all-label-filters

Conversation

@shuaiyuanxx

Copy link
Copy Markdown

What this PR does / why we need it:

NormalizeVolumePruneFilters discarded every filter when the all flag was set, deleting label/label!/until before they reached the filter generator. So podman volume prune --all --filter label=foo ignored the label and pruned every unused volume. all only widens the scope from anonymous-only to all unused volumes; it is orthogonal to the label filters, which must still select which volumes are pruned. The fix drops only the all key and keeps the rest.

How to verify it

go test ./pkg/util/ -run TestNormalizeVolumePruneFilters

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

The existing all true drops all and no anonymous test is unchanged; the fix
only affects requests that combine all with other filters.

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

Fixed volume prune so `label`/`label!` filters are honored together with `--all` (e.g. `podman volume prune --all --filter label=...`).

@Honny1 Honny1 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.

I did a light review. Please rebase onto upstream main to fix the Windows failure. Also, link fixed issue if it exists. Thanks

@shuaiyuanxx shuaiyuanxx force-pushed the fix-volume-prune-all-label-filters branch from bdad3c8 to 35dff6b Compare June 26, 2026 01:09
@shuaiyuanxx

Copy link
Copy Markdown
Author

I did a light review. Please rebase onto upstream main to fix the Windows failure. Also, link fixed issue if it exists. Thanks

Thanks for the review! Rebased onto the latest main. There's no existing issue for this, so I've left the Fixes line as None.

@shuaiyuanxx shuaiyuanxx changed the base branch from main to v6.0 June 26, 2026 01:34
@shuaiyuanxx shuaiyuanxx marked this pull request as draft June 26, 2026 01:35
@shuaiyuanxx shuaiyuanxx changed the base branch from v6.0 to main June 26, 2026 01:39
@shuaiyuanxx shuaiyuanxx marked this pull request as ready for review June 26, 2026 01:41

@danishprakash danishprakash 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.

Thanks, code LGTM but could you please add an integration test for this?

@shuaiyuanxx shuaiyuanxx force-pushed the fix-volume-prune-all-label-filters branch from 35dff6b to 4e4713f Compare June 26, 2026 07:02
@shuaiyuanxx

Copy link
Copy Markdown
Author

Thanks, code LGTM but could you please add an integration test for this?

Thanks! Added an e2e integration test

@danishprakash

Copy link
Copy Markdown
Member

Can you please rebase with main, it should fix the apiv2 failures.

@Honny1 Honny1 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.

This behavior should be documented in the docs.

@shuaiyuanxx shuaiyuanxx force-pushed the fix-volume-prune-all-label-filters branch from 4e4713f to 4dc909d Compare June 29, 2026 09:41
NormalizeVolumePruneFilters discarded every query filter when the "all"
pseudo-filter was set, deleting label/label!/until before they reached the
volume filter generator. As a result `podman volume prune --all --filter
label=foo` ignored the label and pruned every unused volume.

"all" only widens the prune scope from anonymous-only to all unused volumes;
it is orthogonal to the label filters, which must still select which of those
volumes are removed. Drop only the "all" key and keep the remaining filters so
they continue to apply.

NormalizeVolumePruneFilters is shared by the local (abi), remote (libpod API),
and Docker-compat prune paths, so all three were affected.

Signed-off-by: Shuai Yuan <shuaiyuanzju@gmail.com>
@shuaiyuanxx shuaiyuanxx force-pushed the fix-volume-prune-all-label-filters branch from 4dc909d to 4586dc2 Compare June 29, 2026 09:52
@shuaiyuanxx

Copy link
Copy Markdown
Author

This behavior should be documented in the docs.

Done, could you help to review it again? Thanks!

@shuaiyuanxx

Copy link
Copy Markdown
Author

I already rebased to main, but why ci still failed..

@Honny1

Honny1 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

It seems that these failures are flakes. I have rerun the tests.

@Honny1 Honny1 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

PTAL @podman-container-tools/podman-reviewers @podman-container-tools/podman-maintainers

@inknos

inknos commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

LGTM

@Honny1 Honny1 merged commit 5c8a6d5 into podman-container-tools:main Jun 29, 2026
121 of 124 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.

4 participants