Skip to content

Bug 1277046 - fixed tagging ImageStreamImage - #5931

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
soltysh:bug1277046
Nov 23, 2015
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
soltysh:bug1277046

Conversation

@soltysh

@soltysh soltysh commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1277046.

The general take-away is we were unnecessarily expanding docker spec to point to internal registry, instead of pointing to the pull spec from the tag which is the source of the new tag.

@miminar ptal
@ncdc fyi

@liggitt

liggitt commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

does this change the output of the API? can you give a before/after sample output?
@jwforres is the web console using this to correlate images?

@ncdc

ncdc commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

@liggitt this doesn't have any UI changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is ResolveImageID not sufficient? If resolveImageID is not sufficient, add a new method in api that provides it, don't create new code here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to pull spec, which ResolveImageID doesn't provide.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a new method in api/helpers.go that does this - no ugly propagation of util code outside of api.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is almost identical to ResolveImageID method, I'll just extend that method with that parameter? Does it make sense? I'm somehow reluctant in duplicating this code, so I agree with you entirely.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResolveImageID is only used in 2 places currently: here, and in imagestreamimage/rest.go. We know what it's used for here. In rest.go, we use it to get the image ID (sha256:...), which we then use to get the actual Image (which obviously assumes that the image has been imported into etcd).

Let's see if there's a way to modify this method to suit both purposes...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually both of these places expect single result, others (0 or 2+) are interpreted as errors. What if ResolveImageID would actually return the tagevent rather than just the ID, it does now? Additionally returning error, but since rest.go needs distinction between 0 and 2+, we could return NotFound and Conflict errors appropriately, wdyt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that thought as well. One question I have is about the errors - we use fmt.Errorf in one place vs specific error types in the other. If we can resolve what to do about that, +1 for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'll rework this part. I don't worry about errors, the method will return specialized errors and it'll be caller decision what to do about them.

@liggitt

liggitt commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

still not clear, does this change the output of the API?

@ncdc

ncdc commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

No output changes.

Without this change, you get this, which has an incorrect dockerImageReference:

  status:
    tags:
    - items:
      - created: 2015-11-13T18:40:31Z
        dockerImageReference: 172.30.138.254:5000/default/recreate-example@sha256:1318f08b141aa6a4cdca8c09fe8754b6c9f7802f8fc24e4e39ebf93e9d58472b
        image: sha256:1318f08b141aa6a4cdca8c09fe8754b6c9f7802f8fc24e4e39ebf93e9d58472b
      tag: whatever

With this change, you get this:

  status:
    tags:
    - items:
      - created: 2015-11-13T18:40:31Z
        dockerImageReference: openshift/deployment-example@sha256:1318f08b141aa6a4cdca8c09fe8754b6c9f7802f8fc24e4e39ebf93e9d58472b
        image: sha256:1318f08b141aa6a4cdca8c09fe8754b6c9f7802f8fc24e4e39ebf93e9d58472b
      tag: whatever

@liggitt

liggitt commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

I'm pretty sure the UI is using the resolved dockerImageReference to correlate an image with a container. @jwforres can confirm or correct

@ncdc

ncdc commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

This change makes it so the resolved dockerImageReference goes from an invalid pull spec to a valid one. I understand what you're saying, however.

@ncdc

ncdc commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

In other words, without this fix, you'll never be able to start a container that has image: <invalid pull spec> 😄

@liggitt

liggitt commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

I thought container image fields had the fully resolved "172.30.138.254:5000/default/..." pull-spec... is that not the case?

@ncdc

ncdc commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

That is correct for builds/deployments. But the pull spec is still invalid with the specific use case this PR is fixing (see the bz)

@liggitt

liggitt commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

I still am having a hard time understanding how the unresolved pull spec is correct output. Will container images also change to use that format?

@liggitt

liggitt commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

talked on IRC. to clarify, this PR should only affect the output dockerImageReference for external images... images located in the internal registry will continue to return the resolved internal registry IP, etc

@ncdc

ncdc commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

Correct

@soltysh

soltysh commented Nov 20, 2015

Copy link
Copy Markdown
Contributor Author

I've refactored ResolveImageID, though I still want to ensure the code using that method is properly tested before merging this piece.

@soltysh soltysh changed the title Bug 1277046 - fixed tagging ImageStreamImage [DO_NOT_MEREGE] Bug 1277046 - fixed tagging ImageStreamImage Nov 20, 2015
@miminar

miminar commented Nov 20, 2015

Copy link
Copy Markdown
!!! gofmt needs to be run on the following files: 
./pkg/image/api/helper_test.go

@soltysh soltysh changed the title [DO_NOT_MEREGE] Bug 1277046 - fixed tagging ImageStreamImage Bug 1277046 - fixed tagging ImageStreamImage Nov 20, 2015
@soltysh

soltysh commented Nov 20, 2015

Copy link
Copy Markdown
Contributor Author

Could be renamed to something like NewTagEventForImageID()

We don't create new tag (although methods returns new TagEvent object), but rather returning information about a tag. That's why I'll stay with current naming.

The formatting was fixed, from what I see we have gofmt check disabled for go1.5. I'll create a separate PR to address that problem, though.

@soltysh

soltysh commented Nov 20, 2015

Copy link
Copy Markdown
Contributor Author

I've also checked that the methods using ResolveImageID have enough test coverage. After addressing @miminar comments and squashing comments, this is ready for final review.

@soltysh

soltysh commented Nov 20, 2015

Copy link
Copy Markdown
Contributor Author

[test]

Comment thread pkg/image/api/helper.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/exists/exist/

to point to original pull spec instead of the internal registry.
@soltysh

soltysh commented Nov 20, 2015

Copy link
Copy Markdown
Contributor Author

@ncdc fixed

@miminar

miminar commented Nov 23, 2015

Copy link
Copy Markdown

LGTM

@soltysh

soltysh commented Nov 23, 2015

Copy link
Copy Markdown
Contributor Author

re-[test] and if it's green I'll merge this upon getting approval.

@soltysh

soltysh commented Nov 23, 2015

Copy link
Copy Markdown
Contributor Author

I got strange flake in hack/test-cmd.sh, which is working perfectly fine on my machine:

ERROR: gave up waiting for https://127.0.0.1:28443/healthz

re-[test]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 1b71e4e

@openshift-bot

Copy link
Copy Markdown
Contributor

@soltysh

soltysh commented Nov 23, 2015

Copy link
Copy Markdown
Contributor Author

That's what I was waiting for.

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/4112/) (Image: devenv-rhel7_2779)

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 1b71e4e

openshift-bot pushed a commit that referenced this pull request Nov 23, 2015
@openshift-bot
openshift-bot merged commit 1e380fb into openshift:master Nov 23, 2015
@soltysh
soltysh deleted the bug1277046 branch November 24, 2015 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants