Bug 1386917

Summary: Deleting an image should allow references to the image to be deleted from imagestreamtags
Product: OpenShift Container Platform Reporter: Steven Walter <stwalter>
Component: Image RegistryAssignee: Michal Minar <miminar>
Status: CLOSED ERRATA QA Contact: Dongbo Yan <dyan>
Severity: low Docs Contact:
Priority: low    
Version: 3.2.0CC: aos-bugs, bparees, jokerman, jolee, mfojtik, mmccomas, pep
Target Milestone: ---   
Target Release: 3.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: imagestreamtags were not checked for dangling image references Consequence: references to deleted images were kept and pruner used to report warning about that Fix: references to deleted images are now being removed from imagestreamtags Result: pruner will not repeatably complain about dangling image references
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-11-28 21:51:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1267746    

Description Steven Walter 2016-10-19 19:58:29 UTC
Description of problem:

Want to delete imagestreamimage reference within the imagestream without deleting the whole tag.

oc describe is
Name:			php
Created:		6 days ago
Labels:			<none>
Annotations:		openshift.io/image.dockerRepositoryCheck=2016-09-26T15:13:35Z
Docker Pull Spec:	172.30.31.70:5000/default/php

Tag	Spec	Created			PullSpec			Image
5.6	php:5.6	About a minute ago	php@sha256:0a80a0ae5d2993...	<same>
		6 days ago		php@sha256:4780a083d4c44d...	<same>

. . .

===========================================
GOAL: delete the image from "6 days ago", php@sha256:4780a083d4c44d...	

└──> oc get imagestreamimages php@sha256:47
NAME          DOCKER REF                                                                    UPDATED         IMAGENAME
php@4780a08   php@sha256:4780a083d4c44da7db6bb6a850c81d05eb1fdb953deb05dbc6a80b0d7a901851   292 years ago   sha256:4780a083d4c44da7db6bb6a850c81d05eb1fdb953deb05dbc6a80b0d7a901851

└──> oc get imagestreamimages php@4780a08 
NAME          DOCKER REF                                                                    UPDATED         IMAGENAME
php@4780a08   php@sha256:4780a083d4c44da7db6bb6a850c81d05eb1fdb953deb05dbc6a80b0d7a901851   292 years ago   sha256:4780a083d4c44da7db6bb6a850c81d05eb1fdb953deb05dbc6a80b0d7a901851

(both references work)

└──> oc delete imagestreamimages php@sha256:4780a083d4c44da7db6bb6a850c81d05eb1fdb953deb05dbc6a80b0d7a901851
Error from server: the server does not allow this method on the requested resource

Deleting imagestreamimage does not work, but:

└──> oc delete image sha256:4780a083d4c44da7db6bb6a850c81d05eb1fdb953deb05dbc6a80b0d7a901851
image "sha256:4780a083d4c44da7db6bb6a850c81d05eb1fdb953deb05dbc6a80b0d7a901851" deleted

Does. Additionally, after doing so, we can no longer get the imagestreamimage:

└──> oc get imagestreamimages php@4780a08 
Error from server: images "sha256:4780a083d4c44da7db6bb6a850c81d05eb1fdb953deb05dbc6a80b0d7a901851" not found

Yet, the imagestreamimage still shows up in the imagestream:

└──> oc describe is
Name:			php
. . .
Tag	Spec		Created		PullSpec			Image
5.6	<pushed>	7 minutes ago	php@sha256:0a80a0ae5d2993...	<same>
			6 days ago	php@sha256:4780a083d4c44d...	<same>


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

How reproducible:
Reproduced reliably


Additional info:

Possibly an RFE if this was intended behavior to begin with

Comment 1 Maciej Szulik 2016-11-14 10:43:50 UTC
As marked by mfojtik, this is RFE, since only ImageStream is an actual image and we store all the information about ImageStreamImages and ImageStreamTags inside it. That means the two latter are virtual objects (iow. not stored in etcd). 

To fix the current state pruning images should help, since it checks if the connections are still valid and updates them accordingly.

Comment 4 Michal Minar 2017-10-17 14:51:08 UTC
This will be addressed by https://github.com/openshift/origin/pull/16821

Comment 5 Ben Parees 2017-10-17 15:54:13 UTC
to be clear, with the above PR it will still be necessary to 

1) oc delete the image
2) run oc adm prune to clean up the references.

(that is, deleting the image alone will not immediately remove the reference to the image from the imagestreamtag)

But that is an improvement over the current behavior in which pruning will not remove the reference.

Comment 6 Michal Minar 2017-10-31 10:24:14 UTC
The PR has been merged.

Comment 8 Dongbo Yan 2017-11-02 08:19:43 UTC
Verified
# oc version
oc v3.7.0-0.189.0
kubernetes v1.7.6+a08f5eeb62
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https:8443
openshift v3.7.0-0.189.0
kubernetes v1.7.6+a08f5eeb62

Reference 3 images to one imagestreamTag, delete 2 images
# oc delete image sha256:6a448ad9ac44348523cd13fef635ed1ac220a7a0f95b2a5f200f2b42a910d1d6 sha256:c2e5ffc909fc598628caebe56571849cbcbeea6c99f885a9870cb8c5967d5111

prune image from imagestreamTag
# oadm prune images --keep-tag-revisions=1 --keep-younger-than=0 --certificate-authority=ca.crt --registry-url=docker-registry-default.com --confirm

Only one image references to imagestreamTag

Comment 12 errata-xmlrpc 2017-11-28 21:51:43 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, and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHSA-2017:3188