Skip to content

Conversation

@soltysh
Copy link
Contributor

@soltysh soltysh commented Feb 24, 2016

Fixes #7555.

@smarterclayton I've made slight modifications in the image-import command to address problems from the issue. Still there are some others I've marked as TODO for now. ptal

// TODO soltysh: what about the case where specs are only on tags?
if len(stream.Spec.DockerImageRepository) == 0 {
return fmt.Errorf("flag --all is applicable only to images with .spec.dockerImageRepository defined")
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

drop else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right.


if all {
// importing a whole repository
// TODO soltysh: write tests to cover all the possible usecases!!!
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test now that covers the old behavior and new.

@soltysh
Copy link
Contributor Author

soltysh commented Feb 24, 2016

@smarterclayton I've addressed the dot comment. I don't feel comfortable with import image not being tested at all, so I agree with your comment. I'll work on creating extensive tests of the ImageStreamImport created in imageimport.go as a followup if you don't mind.

@smarterclayton
Copy link
Contributor

Even a test-cmd test would be fine now. I'd be happy with 2 or 3 more "import-image" commands added to images.sh

@soltysh
Copy link
Contributor Author

soltysh commented Feb 26, 2016

@smarterclayton I've reworked the image-import command to follow Complete-Validate-Run scheme and split it into testable chunks (commit 1). The bugfix and tests are in 2nd commit. ptal

@soltysh
Copy link
Contributor Author

soltysh commented Feb 26, 2016

[test]

@soltysh
Copy link
Contributor Author

soltysh commented Feb 26, 2016

Fixed gofmt problem.

@soltysh
Copy link
Contributor Author

soltysh commented Feb 27, 2016

One clean run, one flake filled new one for that. @smarterclayton still waiting your signoff.

@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 28, 2016 via email

Run: func(cmd *cobra.Command, args []string) {
err := RunImportImage(f, out, cmd, args)
kcmdutil.CheckErr(err)
if err := opts.Complete(f, args, out); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't force these to be usage errors, return usage errors and call CheckErr directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, Complete doesn't deal with usage errors here, the only ones there are from getting default namespace or clients.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, I must have been looking at older commands before this new pattern. Will change.

@smarterclayton
Copy link
Contributor

Change looks ok, can we add a few more branch tests to hack/test-cmd.sh

@soltysh
Copy link
Contributor Author

soltysh commented Feb 29, 2016

@smarterclayton what kind of tests are you thinking about?

@soltysh
Copy link
Contributor Author

soltysh commented Feb 29, 2016

@smarterclayton I've fixed this one issue, I'll be working on the tests both unit and cmd as a followup. I'd like to add --dry-run you've mentioned as well.

@soltysh
Copy link
Contributor Author

soltysh commented Feb 29, 2016

Let's have this one merged if you don't mind.

@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 29, 2016 via email

@soltysh
Copy link
Contributor Author

soltysh commented Mar 1, 2016

I'd like additional test-cmd tests here before we merge this that work before and after.

  1. Refactored code but without my fix, lines 289-293:
if o.All {
    // importing a whole repository
    if len(from) == 0 {
        from = o.Target
    }

Covers the usecase where an image stream is found and we want to import all tags, without from being passed: oc import-image myis --all. This sets from to be the name of the image stream passed as an argument, which looking down the code is then being passed to importer as:

kapi.ObjectReference{
    Kind: "DockerImage",
    Name: from,
},

Which will generally fail when trying to read image metadata from remote repository. The only use-case where this will work is when your image stream uses the name of the images provided by docker hub (eg. mysql, python, etc.)

  1. Refactored code but without my fix, lines 337-348:
} else {
    // create a new tag
    if len(from) == 0 {
        from = o.Target
    }

Covers the usecase where we import single tag, from existing image stream, but we omit the tag name, assuming default latest will be applied: oc import-image myis. Since the tag is not explicitly specified in the image stream's spec we fail to find it and we fall in the above else case where we again set from to point to image stream name. From this definition we create a latest tag pointing
to:

kapi.ObjectReference{
    Kind: "DockerImage",
    Name: from,
},

Further more we set above ObjectReference in the last else as main image stream's
From, which is not necessarily correct either.

@smarterclayton having said that I'm not sure there was correct behavior before, that I can actually address with tests. I'm ok with adding more tests and I'm currently working on, it but I don't see any before that was actually working, though maybe I'm missing something here. If so please point me to the before usecase you're talking about.

edit: updated code links to current commit

…plit the code so it's testable + added tests.
@soltysh
Copy link
Contributor Author

soltysh commented Mar 1, 2016

@smarterclayton I've addressed your comment and added more tests, ptal

@soltysh
Copy link
Contributor Author

soltysh commented Mar 1, 2016

Of course I forgot to update tests after changing Validate - fixed.

@soltysh
Copy link
Contributor Author

soltysh commented Mar 1, 2016

It looks like flake from #6077

@soltysh
Copy link
Contributor Author

soltysh commented Mar 1, 2016

@smarterclayton comment addressed

@soltysh
Copy link
Contributor Author

soltysh commented Mar 1, 2016

@smarterclayton test with checking no of imported tags. For your question why I've changed from importing mysql to docker.io/mysql is to remove ambiguity for having two mysql, where one is pointing to our image stream and second to hub's image.

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 97b0f7f

@smarterclayton
Copy link
Contributor

smarterclayton commented Mar 1, 2016 via email

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/1754/)

@openshift-bot
Copy link
Contributor

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

@soltysh
Copy link
Contributor Author

soltysh commented Mar 2, 2016

Test flake from #7662, merge flake looks like #6077.
re-[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 97b0f7f

openshift-bot pushed a commit that referenced this pull request Mar 2, 2016
@openshift-bot openshift-bot merged commit 2eb8022 into openshift:master Mar 2, 2016
@soltysh soltysh deleted the issue7555 branch March 3, 2016 07:38
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.

4 participants