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

Allow objects to request resolution, not just images #14795

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

smarterclayton
Copy link
Contributor

@smarterclayton smarterclayton commented Jun 21, 2017

A lot of times, you want to be able to reuse a bit of config that works
fine elsewhere. By adding the alpha.image.policy.openshift.io/resolve-names
annotation with value * to the object you can request that resolution
attempt to match all image references to an image stream tag in the
current namespace, regardless of their own policy. This makes it easy to
transition to looking up image stream tags by name.

Extend oc set image-lookup to accept deploy/foo and to be able to
list and display non image stream resources.

@soltysh @mfojtik [test] this is somewhat last minute, but after using this
more I also wanted to be able to easily flip from using a config template
someone gave me to an image I built in the current namespace, with minimal
pain:

$ oc create -f SOMEONES_KUBE_OBJECT
// hack hack hack, wish i could build an image for hub/foo/bar:latest for this
$ oc new-build somerepo --output=bar:latest
$ oc set image-lookup deploy/mydeploy
// mydeploy magically picks up bar:latest from the image stream

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

I'm additionally missing test-cmd for the oc image-lookup command itself.

namespace for any image that matches, regardless of whether the image stream has lookup
enabled.

$ %[1]s run mysql --image=myregistry:5000/test/mysql:v1
Copy link
Contributor

Choose a reason for hiding this comment

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

Mind fixing the formatting here.

default:
accessor, ok := ometa.GetAnnotationAccessor(info.Object)
if !ok {
fmt.Fprintf(w, "%s/%s\tUNKNOWN\n", info.Mapping.Resource, info.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Make this error message more readable, UNKNOWN is not helpful.
  2. This method allows returning errors, but you're not actually using it anywhere, it would be good to either gather errors in a list and return aggregate, or return at any error. I'd personally went with the former.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't an error message, this is indicating that the provided object doesn't support the annotation. We don't display errors in list views usually, we display something simple. Effectively, this is "unsupported".

Copy link
Contributor

Choose a reason for hiding this comment

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

Having resource/X is not supported seems more understandable in that case.

o.Expect(err).NotTo(o.HaveOccurred())

if pod.Spec.Containers[0].Image != tag.Image.DockerImageReference {
g.Skip("default image resolution is not configured, can't verify pod resolution")
Copy link
Contributor

Choose a reason for hiding this comment

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

This worries me a bit, why do we want to have this skip?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because admins can turn off image resolution.

Copy link
Contributor

Choose a reason for hiding this comment

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

True, but we should make sure we have them on in tests. If we do silent skips, we fail to know when this will break. Don't we?

Copy link
Contributor Author

@smarterclayton smarterclayton Jun 26, 2017

Choose a reason for hiding this comment

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

We can't really split the difference. An upgraded cluster isn't required to have these, so extended tests being skipped is irritating but not essential.

@soltysh
Copy link
Contributor

soltysh commented Jun 21, 2017

And you're missing updated completions.

@smarterclayton smarterclayton force-pushed the policy_2 branch 3 times, most recently from 7ed26b7 to 79f66e9 Compare June 24, 2017 21:56
A lot of times, you want to be able to reuse a bit of config that works
fine elsewhere. By adding the `alpha.image.policy.openshift.io/resolve-names`
annotation with value `*` to the object you can request that resolution
attempt to match all image references to an image stream tag in the
current namespace, regardless of their own policy. This makes it easy to
transition to looking up image stream tags by name.

Extend `oc set image-lookup` to accept `deploy/foo` and to be able to
list and display non image stream resources.
@smarterclayton
Copy link
Contributor Author

smarterclayton commented Jun 27, 2017 via email

@smarterclayton
Copy link
Contributor Author

smarterclayton commented Jun 27, 2017 via email

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

One nit, but this LGTM.

os::cmd::expect_success_and_text "oc set image-lookup secrets --list" "false"

# Clear resources
os::cmd::expect_success "oc delete deploy,dc,rs,rc,pods --all"
Copy link
Contributor

Choose a reason for hiding this comment

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

You're not creating DC, so no need to remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah. I may come back and add one in a follow on.

@soltysh
Copy link
Contributor

soltysh commented Jun 27, 2017

Flake #14043

[merge]

@smarterclayton
Copy link
Contributor Author

[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 7ca6090

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/2730/) (Base Commit: a67ac87) (PR Branch Commit: 7ca6090)

@soltysh
Copy link
Contributor

soltysh commented Jun 28, 2017

Flake #14043

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 7ca6090

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/merge FAILURE (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/1161/) (Base Commit: 6bbad88) (PR Branch Commit: 7ca6090)

@smarterclayton smarterclayton merged commit 20c77cb into openshift:master Jun 28, 2017
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.

3 participants