Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot update ImageStreamTags created via Push #18519

Closed
bparees opened this issue Feb 7, 2018 · 5 comments · Fixed by #18532
Closed

Cannot update ImageStreamTags created via Push #18519

bparees opened this issue Feb 7, 2018 · 5 comments · Fixed by #18532
Assignees
Labels
component/image kind/bug Categorizes issue or PR as related to a bug. priority/P2

Comments

@bparees
Copy link
Contributor

bparees commented Feb 7, 2018

When an image is push to the internal registry, an imagestreamtag is created in the form:

kind: ImageStreamTag
lookupPolicy:
  local: false
metadata:
  creationTimestamp: 2018-02-07T22:06:42Z
  name: foobar:latest
  namespace: p1
  resourceVersion: "2545"
  selfLink: /apis/image.openshift.io/v1/namespaces/p1/imagestreamtags/foobar%3Alatest
  uid: 2dd34eef-0c53-11e8-9652-507b9d27b5d9
tag: null

Now, normally when an IST is created or updated, the associated imagestream is also updated to add the IST to the imagestream.spec.tags list.

However when the IST is created via push, it is created via an imagestreammapping which means that the imagestream associated w/ the IST is not updated. So the imagestream has a nil spec.tag list.

If you then attempt to update the ImageStreamTag manually (e.g. oc edit, to add an annotation to it), the IST update logic attempts to add the IST to the imagestream spec list, except that the IST we're adding is a TagReference with no information(see tag: null above), including notably no ReferencePolicyType value.

https://github.com/openshift/origin/blob/master/pkg/image/registry/imagestreamtag/rest.go#L262-L280

This results in us attempting to run the ImageStream validation logic on the imagestream and failing here:
https://github.com/openshift/origin/blob/master/pkg/image/registry/imagestream/strategy.go#L543
https://github.com/openshift/origin/blob/master/pkg/image/apis/image/validation/validation.go#L281-L299
https://github.com/openshift/origin/blob/master/pkg/image/apis/image/validation/validation.go#L201-L204
https://github.com/openshift/origin/blob/master/pkg/image/apis/image/validation/validation.go#L265-L269

Now, the imagestreamtag itself does not have a ReferencePolicyType because it doesn't even have a TagReference (note tag: null above). (If it did have a TagReference it would have had the ReferencePolicy defaulted because we have a defaulter for this).

But we seemingly manufacture a TagReference out of thin air here (with, again an empty ReferencePolicyType):
https://github.com/openshift/origin/blob/master/pkg/image/registry/imagestreamtag/rest.go#L265

Which again bypasses defaulting behavior.

So we create a TagReference that doesn't have a ReferencePolicyType, we add that TagReference to the ImageStream.spec.tags, and then try to run it through validation and fail.

Here are my questions:

  1. why are we trying to add ISTs to ISes when editing an IST? Shouldn't it be reasonable to assume the IST is already listed in the IS if it's supposed to be?

  2. why aren't "pushed" ISTs represented in IS.spec.tags upon creation? it's not like i can't import an image from the internal registry. It seems silly to treat them specially.

  3. What's the right fix there? I see three options:
    a) stop adding tag refs to imagestreams during an IST update, period (see above, i don't know why we do this)
    b) variant on (a) - don't add the tag to the IST if the IST's tagreference field is null.
    c) add the ReferencePolicy to the "manufactured" TagRef so the IS update succeeds (essentially re-implement defaulting). Probably wrong because it's going to result in the tagref being added to the IS if someone updates the IST, and that doesn't seem to be the current expected behavior.

@mfojtik @smarterclayton @legionus @dmage @miminar @deads2k

@bparees bparees added kind/bug Categorizes issue or PR as related to a bug. priority/P2 component/image labels Feb 7, 2018
@bparees bparees self-assigned this Feb 7, 2018
@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 7, 2018 via email

@bparees
Copy link
Contributor Author

bparees commented Feb 7, 2018

I think it may be acceptable to not tag the IST if the tag reference is nil, but i'm not positive that's backwards compatible.

As it stands today, no one can update an IST if the tag ref is nil, so the only thing we'd be breaking is now those updates would succeed(while still not updating the IS) instead of failing entirely.

@mfojtik
Copy link
Contributor

mfojtik commented Feb 8, 2018

/cc deads2k

@bparees
Copy link
Contributor Author

bparees commented Feb 8, 2018

ok so (as i come to understand the image resource apis), adding an annotation to an imagestreamtag necessarily requires adding the tag to the imagestream.spec. So for a tag that was only pushed, you literally cannot add annotations to it, unless you're willing to accept that said tag gets added to imagestream.spec in the process.

I can make that happen (by defaulting the referencepolicy as we're updating the imagestream) but do we even want to enable this flow, or is it basically "working as designed" that you can't update an imagestreamtag that doesn't exist in the imagestream.spec?

@bparees
Copy link
Contributor Author

bparees commented Feb 14, 2018

An IST update today is supposed to mean "update spec tag" if tag ref is non nil.

So basically (I'm realizing) it's impossible to update an IST if there is no imagestream.spec.tag for it because there is nowhere to store the update content. The error may not be great(users get a weird validation error reported from the imagestream, when they were trying to update the imagestreamtag), but the behavior seemingly can't be fixed (the only way to add annotations to a pushed IST would be to manufacture a spec tag and add the annotations to it...and it's seemingly a design point that pushed tags don't have a spec tag).

openshift-merge-robot added a commit that referenced this issue Mar 7, 2018
Automatic merge from submit-queue (batch tested with PRs 18587, 18296, 18667, 18665, 18532).

explicitly prohibit updates to imagestream tags that are not spec tags

fixes #18519
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/image kind/bug Categorizes issue or PR as related to a bug. priority/P2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants