Bug 1414267 - oadm prune images with namespace flag does not work
Summary: oadm prune images with namespace flag does not work
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Image Registry
Version: 3.4.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Maciej Szulik
QA Contact: Wei Sun
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-01-18 08:44 UTC by XiaochuanWang
Modified: 2017-03-08 18:43 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
This was not a bug, but an expected behavior. No doc update needed, in that case.
Clone Of:
Environment:
Last Closed: 2017-02-16 21:02:01 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description XiaochuanWang 2017-01-18 08:44:01 UTC
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=''

Comment 1 Maciej Szulik 2017-01-20 09:24:48 UTC
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.

Comment 2 Maciej Szulik 2017-01-20 09:32:58 UTC
I've added a note in prune image docs about that fact:
https://github.com/openshift/openshift-docs/pull/3544

Comment 3 XiaochuanWang 2017-01-22 02:14:42 UTC
Doc PR is merged and it LGTM

Comment 4 Troy Dawson 2017-02-16 21:02:01 UTC
This bug was fixed with the latest OCP 3.4.0 that is already released.


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