Bug 1386917 - Deleting an image should allow references to the image to be deleted from imagestreamtags
Summary: Deleting an image should allow references to the image to be deleted from ima...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Image Registry
Version: 3.2.0
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 3.7.0
Assignee: Michal Minar
QA Contact: Dongbo Yan
URL:
Whiteboard:
Depends On:
Blocks: 1267746
TreeView+ depends on / blocked
 
Reported: 2016-10-19 19:58 UTC by Steven Walter
Modified: 2021-12-10 14:46 UTC (History)
7 users (show)

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
Clone Of:
Environment:
Last Closed: 2017-11-28 21:51:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3584061 0 None None None 2018-08-23 17:51:39 UTC
Red Hat Product Errata RHSA-2017:3188 0 normal SHIPPED_LIVE Moderate: Red Hat OpenShift Container Platform 3.7 security, bug, and enhancement update 2017-11-29 02:34:54 UTC

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


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