Description of problem: cluster admin prune images without namespace limit can prune image, but it does not work when add flag "-n" or "--namespace" Version-Release number of selected component (if applicable): Both openshift and oadm: v3.4.0.39 How reproducible: Always Steps to Reproduce: Use cluster-admin user login on cli locally: master side: $ oadm policy add-cluster-role-to-user cluster-admin xiaocwan local side: # oc login -u xiaocwan -p password 1. # oc new-project xiaocwan-st 2. # oc process -f https://raw.githubusercontent.com/openshift/origin/master/examples/sample-app/application-template-stibuild.json | oc create -f - 3. Delete all resources as below: oc delete is/origin-ruby-sample oc delete is/ruby-22-centos7 oc delete dc/database oc delete dc/frontend oc delete rc/database-1 oc delete rc/frontend-1 oc delete svc/database oc delete svc/frontend 4. # oadm prune images Dry run enabled - no modifications will be made. Add --confirm to remove images Deleting registry layer blobs ... BLOB sha256:0dd4f812e6cca8d571cca550c1b9e46c7db8b9ca3172a542bd3d6161eb2ae900 Deleting images from server ... IMAGE sha256:78fc445678f3d22946a2ee79b12dbfe6f41def30cf61b6adee55c54036c937e4 5. # oc get image|grep 678f3d2294 sha256:78fc445678f3d22946a2ee79b12dbfe6f41def30cf61b6adee55c54036c937e4 172.30.206.2:5000/xiaocwan-st/origin-ruby-sample@sha256:78fc445678f3d22946a2ee79b12dbfe6f41def30cf61b6adee55c54036c937e4 6. # oadm prune images --namespace=xiaocwan-st (or -n xiaocwan-st) Dry run enabled - no modifications will be made. Add --confirm to remove images Actual results: 6. Prune images for namespace "xiaocwan-st" returns no image. Expected results: 6. Prune images for namespace "xiaocwan-st" with dry-run mode should output same result as step 4 Additional info: `oadm options` contains the flag for namespace: -n, --namespace=''
Images are non-namespaced resources, thus can't be removed when namespace is specified. Only ImageStreams will be removed in those cases. The reason for that is that there might be other ImageStreams in other namespaces pointing to that Image, but since we're restricting the pruning to a single namespace we don't know that, thus not removing images.
I've added a note in prune image docs about that fact: https://github.com/openshift/openshift-docs/pull/3544
Doc PR is merged and it LGTM
This bug was fixed with the latest OCP 3.4.0 that is already released.