Bug 2083999 - "--prune-over-size-limit" is not working as expected
Summary: "--prune-over-size-limit" is not working as expected
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.8
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
: 4.11.0
Assignee: Oleg Bulatov
QA Contact: zhou ying
Depends On:
Blocks: 2086969
TreeView+ depends on / blocked
Reported: 2022-05-11 07:50 UTC by Poornima Singour
Modified: 2022-08-10 11:11 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: When filtering over-sized images, the recent images where omitted. Consequence: It wasn't possible to prune big images, if they were rather new in the cluster. Fix: Properly apply filtering rules when looking for image candidates for pruning. Result: It's possible to correctly prune images exceeding given size.
Clone Of:
Last Closed: 2022-08-10 11:11:18 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Github openshift oc pull 1143 0 None open Bug 2083999: Delete recently created images when --prune-over-size-limit is used 2022-05-16 14:26:16 UTC
Red Hat Product Errata RHSA-2022:5069 0 None None None 2022-08-10 11:11:45 UTC

Description Poornima Singour 2022-05-11 07:50:35 UTC
Description of problem:

"oc adm prune images --prune-over-size-limit -n <namespace>"., is not working as expected. We have set the limit on the project as 1M and all the images in the registry are more than 1M, Still when we are trying to use --prune-over-size-limit option to delete the images, it not delete and giving below logs:

I0509 11:07:37.071872   73997 prune.go:893] imagestream openshift/tests: tag latest: revision 1: keeping sha256:d19869b0107d9c6a3c88a274441de92d148de33576ee5f015547e57e2ec88ba4 because of --keep-younger-than
I0509 11:07:37.071886   73997 prune.go:893] imagestream openshift/tests: tag latest: revision 2: keeping sha256:0694873d36244589d44a4f522b1587a333ef33f93acb45866501cba4cdb94b02 because of --keep-younger-than
I0509 11:07:37.071894   73997 prune.go:893] imagestream openshift/tests: tag latest: revision 3: keeping sha256:fcb99aa10e36fa1f706685899780238c0f4801ace8b14340ec1a0a7e0758624f because of --keep-younger-than
Summary: deleted 0 objects

Looking at the code, this particular error message only comes up when pruning an imagestreamtag [0] which I believe is different from an image.
[0] https://github.com/openshift/oc/blob/master/pkg/cli/admin/prune/imageprune/prune.go#L893

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. oc adm prune images --prune-over-size-limit -n <namespace>

Actual results:

- In summary we see deleted object as 0 sha256:fcb99aa10e36fa1f706685899780238c0f4801ace8b14340ec1a0a7e0758624f because of --keep-younger-than
Summary: deleted 0 objects

Expected results:
It should prune the images using --prune-over-size-limit

Additional info:

Comment 2 Oleg Bulatov 2022-05-11 11:19:33 UTC
Lowering severity as it doesn't cause data loss and it's not an upgrade blocker.

Also it should be possible to workaround the problem by explicitly providing `--keep-younger-than=0s`.

Comment 8 zhou ying 2022-05-23 10:08:33 UTC
could reproduced with older version :

./oc version --client
Client Version: 4.8.38

./oc adm prune images --prune-over-size-limit -v 8 > prune_output_old.txt 2>&1
[root@localhost ~]# cat prune_output_old.txt |grep "keep-younger-than"
I0523 18:06:26.281328   36478 prune.go:894] imagestream openshift/installer-artifacts: tag latest: revision 1: keeping sha256:d30a1108c677ac241b143bc0375d3b6eafb8928e4ef0647efef14f1f15c3dd68 because of --keep-younger-than
I0523 18:06:26.281419   36478 prune.go:894] imagestream openshift/fuse7-eap-openshift-java11: tag 1.10: revision 1: keeping sha256:4c7470a39df37f1f158e177dbba7f5aad2c00ce7c6b9be490a8275488fe1b9e1 because of --keep-younger-than

But can't reproduce with latest oc version :

 oc version --client
Client Version: 4.11.0-0.nightly-2022-05-20-213928
Kustomize Version: v4.5.4

oc adm prune images --prune-over-size-limit -v 8 > prune_output.txt 2>&1

cat prune_output.txt |grep "keep-younger-than"

Comment 10 errata-xmlrpc 2022-08-10 11:11:18 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: OpenShift Container Platform 4.11.0 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.