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

Limits the amount of suggestions of a faulty new-build command to 5, fixes #7729 #9353

Merged
merged 1 commit into from Jul 13, 2016
Merged

Limits the amount of suggestions of a faulty new-build command to 5, fixes #7729 #9353

merged 1 commit into from Jul 13, 2016

Conversation

oatmealraisin
Copy link

@oatmealraisin oatmealraisin commented Jun 15, 2016

Limits the amount of suggestions of a faulty new-build command to 5, with highest match score appearing first.

fixes #7729

Old output:

oc new-build -D $'FROM openshft/origin:v1.1\nENV ok=1' --to origin-test:v1.1
error: multiple images or templates matched "openshft/origin:v1.1": 15

The argument "openshft/origin:v1.1" could apply to the following Docker images, OpenShift image streams, or templates:

* Docker image "openshift/origin-base:latest", 3788e83, from local, 74.943mb
  Use --docker-image="openshift/origin-base:latest" to specify this image or template

* Docker image "docker.io/openshift/origin:latest", 819ca62, from local, 133.052mb
  Use --docker-image="docker.io/openshift/origin:latest" to specify this image or template

* Docker image "myproject/origin-test-1:6c16fcd3", 783819e, from local
  Use --docker-image="myproject/origin-test-1:6c16fcd3" to specify this image or template

* Docker image "openshift/origin-release:latest", 8968bf1, from local, 412.836mb
  Use --docker-image="openshift/origin-release:latest" to specify this image or template

* Docker image "openshift/origin-haproxy-router-base:latest", eeadaef, from local, 18.243mb
  Use --docker-image="openshift/origin-haproxy-router-base:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-docker-builder:latest", b171beb, from local
  Use --docker-image="docker.io/openshift/origin-docker-builder:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-docker-registry:latest", b2fbc24, from local, 48.080mb
  Use --docker-image="docker.io/openshift/origin-docker-registry:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-sti-builder:latest", 7464c40, from local
  Use --docker-image="docker.io/openshift/origin-sti-builder:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-deployer:latest", b449a8c, from local
  Use --docker-image="docker.io/openshift/origin-deployer:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-haproxy-router:latest", e77286e, from local, 18.265mb
  Use --docker-image="docker.io/openshift/origin-haproxy-router:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-docker-builder:v1.3.0-alpha.1", 51ecec8, from local
  Use --docker-image="docker.io/openshift/origin-docker-builder:v1.3.0-alpha.1" to specify this image or template

* Docker image "docker.io/openshift/origin-deployer:v1.3.0-alpha.1", 8dcfa74, from local
  Use --docker-image="docker.io/openshift/origin-deployer:v1.3.0-alpha.1" to specify this image or template

* Docker image "docker.io/openshift/origin-pod:latest", cf08328, from local, 1.517mb
  Use --docker-image="docker.io/openshift/origin-pod:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-docker-registry:v1.3.0-alpha.1", 8663602, from local, 45.227mb
  Use --docker-image="docker.io/openshift/origin-docker-registry:v1.3.0-alpha.1" to specify this image or template

* Docker image "docker.io/openshift/origin-pod:v1.3.0-alpha.1", 1086c95, from local, 1.517mb
  Use --docker-image="docker.io/openshift/origin-pod:v1.3.0-alpha.1" to specify this image or template

New output:

oc new-build -D $'FROM openshft/origin:v1.1\nENV ok=1' --to origin-test:v1.1
error: multiple images or templates matched "openshft/origin:v1.1": 15

The argument "openshft/origin:v1.1" could apply to the following Docker images, OpenShift image streams, or templates:

* Docker image "openshift/origin-base:latest", 3788e83, from local, 74.943mb
  Use --docker-image="openshift/origin-base:latest" to specify this image or template

* Docker image "docker.io/openshift/origin:latest", 819ca62, from local, 133.052mb
  Use --docker-image="docker.io/openshift/origin:latest" to specify this image or template

* Docker image "myproject/origin-test-1:6c16fcd3", 783819e, from local
  Use --docker-image="myproject/origin-test-1:6c16fcd3" to specify this image or template

* Docker image "openshift/origin-release:latest", 8968bf1, from local, 412.836mb
  Use --docker-image="openshift/origin-release:latest" to specify this image or template

* Docker image "openshift/origin-haproxy-router-base:latest", eeadaef, from local, 18.243mb
  Use --docker-image="openshift/origin-haproxy-router-base:latest" to specify this image or template

@bparees

@smarterclayton
Copy link
Contributor

That sort order doesn't look right - I would expect origin-base to be below origin:latest. Where's v1.1*?

@oatmealraisin
Copy link
Author

@smarterclayton At some point the v1.1 gets ignored and it returns latest. Any idea where this could be? I've been looking, can't find it. From what I've been reading in code, the openshift/origin:v1.1 is passed as one term to the search. This may also solve the origin-base issue.

@smarterclayton
Copy link
Contributor

I think we want to implement a scoring sort that does closeness based on
heuristics that alters the high level sort.

On Jun 21, 2016, at 11:30 AM, Ryan Murphy notifications@github.com wrote:

@smarterclayton https://github.com/smarterclayton At some point the v1.1
gets ignored and it returns latest. Any idea where this could be? I've been
looking, can't find it. From what I've been reading in code, the
openshift/origin:v1.1 is passed as one term to the search. This may also
solve the origin-base issue.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9353 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ABG_p5bb-C1zAraEqiqjzuO36RY4Fe5Hks5qOAOkgaJpZM4I2t4_
.

@oatmealraisin
Copy link
Author

Based on dockerimagelookup.go:matchTag() and scorers.go:partialScorer(), it looks like we already implement pretty specific scoring, which gets sorted by sort.Sort. As for the v1.1 vs latest, I only had :latest images on my machine. If I pull older images, it returns those as well.

After a rebase, I've tried to reproduce docker.io/openshift/origin:latest being second on the list, but it is now returned as the top result.

Output is now:

 oc new-build -D $'FROM openshft/origin:v1.1\nENV ok=1' --to origin-test:v1.1
error: multiple images or templates matched "openshft/origin:v1.1": 12

The argument "openshft/origin:v1.1" could apply to the following Docker images, OpenShift image streams, or templates:

* Docker image "docker.io/openshift/origin:latest", 3f9c6ac, from local, 143.030mb
  Use --docker-image="docker.io/openshift/origin:latest" to specify this image or template

* Docker image "openshift/origin-base:latest", 3788e83, from local, 74.943mb
  Use --docker-image="openshift/origin-base:latest" to specify this image or template

* Docker image "openshift/origin-release:latest", 8968bf1, from local, 412.836mb
  Use --docker-image="openshift/origin-release:latest" to specify this image or template

* Docker image "openshift/origin-haproxy-router-base:latest", eeadaef, from local, 18.243mb
  Use --docker-image="openshift/origin-haproxy-router-base:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-deployer:v1.3.0-alpha.2", 9dd34e7, from local
  Use --docker-image="docker.io/openshift/origin-deployer:v1.3.0-alpha.2" to specify this image or template

@bparees @smarterclayton ptal?

@bparees
Copy link
Contributor

bparees commented Jul 8, 2016

and what happens if you also have an "openshift/origin-test:v1.1.2" image and look for origin-test:v1.1?

@oatmealraisin
Copy link
Author

An exact match would occur with origin-test:v1.1, partial match for v1.1.2 using the search term as a prefix. Because of the partial match, the process errors out.

The result is:

oc new-build -D $'FROM origin-test:v1.1\nENV ok=1' --to origin-test:v1.1
error: multiple images or templates matched "origin-test:v1.1": 3

The argument "origin-test:v1.1" could apply to the following Docker images, OpenShift image streams, or templates:

* Docker image "openshift/origin-test:v1.1.2", e934940, from local, author The CentOS Project <cloud-ops@centos.org>
  Use --docker-image="openshift/origin-test:v1.1.2" to specify this image or template

* Docker image "openshift/origin-test:v1.1.1", e934940, from local, author The CentOS Project <cloud-ops@centos.org>
  Use --docker-image="openshift/origin-test:v1.1.1" to specify this image or template

* Docker image "docker.io/openshift/origin:latest", 3f9c6ac, from local, 143.030mb
  Use --docker-image="docker.io/openshift/origin:latest" to specify this image or template

I added openshift/origin-test:v1.1.1 to test what would happen with multiple version numbers.

@bparees
Copy link
Contributor

bparees commented Jul 8, 2016

thanks. Just wanted to confirm it appears before :latest in the list.

@bparees
Copy link
Contributor

bparees commented Jul 8, 2016

@oatmealraisin you might experiment w/ retagging things on your machine. I suspect whether origin or origin-base shows up first depends on which one was tagged/created more recently on your local machine, as opposed to a definitive order. It would be good to check that before we conclude it's working correctly.

@oatmealraisin
Copy link
Author

I changed the scoring so that the versions are prefixed, so v1.1 will partially match with v1.1*, etc.
@bparees ptal?

@bparees
Copy link
Contributor

bparees commented Jul 8, 2016

lgtm. @smarterclayton was there a reason you didn't want to partially score the tags? (or anything else for that matter?)

@oatmealraisin
Copy link
Author

[test]

@smarterclayton
Copy link
Contributor

smarterclayton commented Jul 9, 2016 via email

@bparees
Copy link
Contributor

bparees commented Jul 9, 2016

actually i'm going to retract that. if we're cutting the result list at 5, we should print a message letting the user know that not all matches are being displayed.

@smarterclayton
Copy link
Contributor

Yeah, and tell them to use -S to do it (I assume -S doesn't trim, right?)

On Sat, Jul 9, 2016 at 11:13 AM, Ben Parees notifications@github.com
wrote:

actually i'm going to retract that. if we're cutting the result list at 5,
we should print a message letting the user know that not all matches are
being displayed.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9353 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABG_pzFybz5peMkRgF58zT1CGmYNi9v4ks5qT7qcgaJpZM4I2t4_
.

@oatmealraisin
Copy link
Author

@smarterclayton
I thought that new-build didn't have -S? Should we point them at new-app -S --dry-run?

@oatmealraisin
Copy link
Author

re[test]

@smarterclayton
Copy link
Contributor

New-build should have -S. IF we haven't added it yet.... well... that makes this harder. I assume you fixed new-app as well?

@oatmealraisin
Copy link
Author

oatmealraisin commented Jul 11, 2016

new-build doesn't have -S. Should be pretty easy to implement, though! Maybe have a more general oc search? Or point at docker command?

This should fix anything that returns a ErrMulti, so I believe it fixes new-app.

Old output of a mistyped or not found image in a new-build call
would return all possibly matching images.  This commit limits
that to five, and instead suggests using the new-app search function.
Does not make search suggestion if there are less than 5 matches.

As a side fix, we also now check for version prefixing, so v1.1
will partially match to v1.1.1 and v1.1.2.
@oatmealraisin
Copy link
Author

Added some logic to point at oc new-app -S <input> only if we cut output. Otherwise, proceed as normal.

Previous output, more than 5 results:

oc new-build -D $'FROM openshif/origin:v1.1\nENV ok=1' --to origin-test:v1.1
error: multiple images or templates matched "openshif/origin:v1.1": 8

The argument "openshif/origin:v1.1" could apply to the following Docker images, OpenShift image streams, or templates:

* Docker image "openshift/origin-release:latest", 8968bf1, from local, 412.836mb
  Use --docker-image="openshift/origin-release:latest" to specify this image or template

* Docker image "openshift/origin-haproxy-router-base:latest", eeadaef, from local, 18.243mb
  Use --docker-image="openshift/origin-haproxy-router-base:latest" to specify this image or template

* Docker image "openshift/origin-base:latest", 3788e83, from local, 74.943mb
  Use --docker-image="openshift/origin-base:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-release:latest", 9d53669, from local
  Use --docker-image="docker.io/openshift/origin-release:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-base:latest", 811acd6, from local
  Use --docker-image="docker.io/openshift/origin-base:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-deployer:v1.3.0-alpha.1", 8dcfa74, from local
  Use --docker-image="docker.io/openshift/origin-deployer:v1.3.0-alpha.1" to specify this image or template

* Docker image "docker.io/openshift/origin-docker-registry:v1.3.0-alpha.1", 8663602, from local, 45.227mb
  Use --docker-image="docker.io/openshift/origin-docker-registry:v1.3.0-alpha.1" to specify this image or template

* Docker image "docker.io/openshift/origin-pod:v1.3.0-alpha.1", 1086c95, from local, 1.517mb
  Use --docker-image="docker.io/openshift/origin-pod:v1.3.0-alpha.1" to specify this image or template

New output, more than 5 results:

oc new-build -D $'FROM openshif/origin:v1.1\nENV ok=1' --to origin-test:v1.1
error: multiple images or templates matched "openshif/origin:v1.1": 8

The argument "openshif/origin:v1.1" could apply to the following Docker images, OpenShift image streams, or templates:

* Docker image "openshift/origin-release:latest", 8968bf1, from local, 412.836mb
  Use --docker-image="openshift/origin-release:latest" to specify this image or template

* Docker image "openshift/origin-haproxy-router-base:latest", eeadaef, from local, 18.243mb
  Use --docker-image="openshift/origin-haproxy-router-base:latest" to specify this image or template

* Docker image "openshift/origin-base:latest", 3788e83, from local, 74.943mb
  Use --docker-image="openshift/origin-base:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-release:latest", 9d53669, from local
  Use --docker-image="docker.io/openshift/origin-release:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-base:latest", 811acd6, from local
  Use --docker-image="docker.io/openshift/origin-base:latest" to specify this image or template

To view a full list of matches, use 'oc new-app -S openshif/origin:v1.1'

Previous output, less than 5 results:

oc new-build -D $'FROM openshif/origin:v1.1\nENV ok=1' --to origin-test:v1.1
error: multiple images or templates matched "openshif/origin:v1.1": 4

The argument "openshif/origin:v1.1" could apply to the following Docker images, OpenShift image streams, or templates:

* Docker image "openshift/origin-haproxy-router-base:latest", eeadaef, from local, 18.243mb
  Use --docker-image="openshift/origin-haproxy-router-base:latest" to specify this image or template

* Docker image "openshift/origin-base:latest", 3788e83, from local, 74.943mb
  Use --docker-image="openshift/origin-base:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-docker-registry:v1.3.0-alpha.2", f729de7, from local, 48.080mb
  Use --docker-image="docker.io/openshift/origin-docker-registry:v1.3.0-alpha.2" to specify this image or template

* Docker image "docker.io/openshift/origin-pod:v1.3.0-alpha.2", b8d4571, from local, 1.517mb
  Use --docker-image="docker.io/openshift/origin-pod:v1.3.0-alpha.2" to specify this image or template

New output, less than 5 results:

oc new-build -D $'FROM openshif/origin:v1.1\nENV ok=1' --to origin-test:v1.1
error: multiple images or templates matched "openshif/origin:v1.1": 4

The argument "openshif/origin:v1.1" could apply to the following Docker images, OpenShift image streams, or templates:

* Docker image "openshift/origin-haproxy-router-base:latest", eeadaef, from local, 18.243mb
  Use --docker-image="openshift/origin-haproxy-router-base:latest" to specify this image or template

* Docker image "openshift/origin-base:latest", 3788e83, from local, 74.943mb
  Use --docker-image="openshift/origin-base:latest" to specify this image or template

* Docker image "docker.io/openshift/origin-docker-registry:v1.3.0-alpha.2", f729de7, from local, 48.080mb
  Use --docker-image="docker.io/openshift/origin-docker-registry:v1.3.0-alpha.2" to specify this image or template

* Docker image "docker.io/openshift/origin-pod:v1.3.0-alpha.2", b8d4571, from local, 1.517mb
  Use --docker-image="docker.io/openshift/origin-pod:v1.3.0-alpha.2" to specify this image or template

@oatmealraisin
Copy link
Author

[test]

@oatmealraisin
Copy link
Author

@bparees @smarterclayton ptal?

t.Errs...,
)

return
Copy link
Contributor

Choose a reason for hiding this comment

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

probably safer to break instead of return, lest we add additional processing/output at the bottom of this method.

Copy link
Contributor

Choose a reason for hiding this comment

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

nm, i see why you returned. this is fine.

@bparees
Copy link
Contributor

bparees commented Jul 12, 2016

lgtm
[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Jul 12, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6171/) (Image: devenv-rhel7_4576)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 989fbf1

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 989fbf1

@openshift-bot
Copy link
Contributor

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

@openshift-bot openshift-bot merged commit 0a62748 into openshift:master Jul 13, 2016
@smarterclayton
Copy link
Contributor

Quick question - you showed:

oc new-build -D $'FROM openshif/origin:v1.1\nENV ok=1' --to origin-test:v1.1
error: multiple images or templates matched "openshif/origin:v1.1": 8

The argument "openshif/origin:v1.1" could apply to the following
Docker images, OpenShift image streams, or templates:

  • Docker image "openshift/origin-release:latest", 8968bf1, from local, 412.836mb
    Use --docker-image="openshift/origin-release:latest" to specify this
    image or template
  • Docker image "openshift/origin-haproxy-router-base:latest", eeadaef,
    from local, 18.243mb
    Use --docker-image="openshift/origin-haproxy-router-base:latest" to
    specify this image or template
  • Docker image "openshift/origin-base:latest", 3788e83, from local, 74.943mb
    Use --docker-image="openshift/origin-base:latest" to specify this
    image or template
  • Docker image "docker.io/openshift/origin-release:latest", 9d53669, from local
    Use --docker-image="docker.io/openshift/origin-release:latest" to
    specify this image or template
  • Docker image "docker.io/openshift/origin-base:latest", 811acd6, from local
    Use --docker-image="docker.io/openshift/origin-base:latest" to
    specify this image or template

To view a full list of matches, use 'oc new-app -S openshif/origin:v1.1'

Why is openshift/origin:v1.1 not the top match? None of those others are
even close?

On Tue, Jul 12, 2016 at 8:21 PM, OpenShift Bot notifications@github.com
wrote:

Merged #9353 #9353.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9353 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ABG_p5azgJSCEagCUjuRhvmnW2Rovam-ks5qVC-ggaJpZM4I2t4_
.

@bparees
Copy link
Contributor

bparees commented Jul 13, 2016

i don't think @oatmealraisin actually had the "openshif/origin:v1.1" tag in his local docker daemon. notice it wasn't in the full listing either (the "previous output" example)

@oatmealraisin
Copy link
Author

oatmealraisin commented Jul 13, 2016

@smarterclayton like @bparees said I didn't have any closer images unfortunately. I had been messing with my docker images, so they are a bit odd. I tested the v1.1 functionality earlier in the thread, if that helps!

@smarterclayton
Copy link
Contributor

OK.

On Tue, Jul 12, 2016 at 10:06 PM, Ryan Murphy notifications@github.com
wrote:

@smarterclayton https://github.com/smarterclayton like bparees I didn't
have any closer images unfortunately. I had been messing with my docker
images, so they are a bit odd. I tested the v1.1 functionality earlier in
the thread, if that helps!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9353 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABG_p4hDkYKuJri4Xr11rOSZNmXaspG3ks5qVEg1gaJpZM4I2t4_
.

@oatmealraisin oatmealraisin deleted the rymurphy_7729 branch July 13, 2016 12:50
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.

Excessive output when multiple images returned for new-app on big repository.
4 participants