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

Adds resolver to provide task resolution for images #2137

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

sthaha
Copy link
Member

@sthaha sthaha commented Mar 3, 2020

Changes

This partially addresses the desire to fetch tasks
from an OCI image artifact.

Issue: #1839

Signed-off-by: Sunil Thaha sthaha@redhat.com

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

Describe any user facing changes here, or delete this block.

Examples of user facing changes:
- API changes
- Bug fixes
- Any changes in behavior

@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 3, 2020
@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Mar 3, 2020
@tekton-robot tekton-robot requested review from imjasonh and a user March 3, 2020 07:44
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 3, 2020
@sthaha sthaha changed the title WIP: Add resolver to provide task resolution for images Adds resolver to provide task resolution for images Mar 4, 2020
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 4, 2020
}

func (o OCIResolver) readImageLayer(kind string, name string) ([]byte, error) {
// TODO: When this is moved into the Tekton controller, authorize this
Copy link
Member Author

Choose a reason for hiding this comment

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

This will be addressed in a follow up patch as the change seems rather large

Copy link
Member

Choose a reason for hiding this comment

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

Do worry too much about it, we've seen way larger changes 😉

Choose a reason for hiding this comment

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

So should this be all done in one PR or in multiple?

Copy link
Member

Choose a reason for hiding this comment

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

depend what you mean by "all". But having a full working pkg/remote/oci.go file (aka at least with the serviceAccount support, the validation too) works, then other PR to start integrating it into the reconcilier would be others.

@sthaha
Copy link
Member Author

sthaha commented Mar 4, 2020

/test tekton-pipeline-unit-tests

@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 4, 2020
}

func (o OCIResolver) readImageLayer(kind string, name string) ([]byte, error) {
// TODO: When this is moved into the Tekton controller, authorize this
Copy link
Member

Choose a reason for hiding this comment

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

Do worry too much about it, we've seen way larger changes 😉

Comment on lines 34 to 41
func init() {
// Add Tekton's resources to the K8s deserializer
schemeBuilder := runtime.NewSchemeBuilder(v1beta1.AddToScheme)
err := schemeBuilder.AddToScheme(scheme.Scheme)
if err != nil {
log.Panic(err)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

why is it required ? 🤔

@vdemeester vdemeester added kind/design Categorizes issue or PR as related to design. kind/feature Categorizes issue or PR as related to a new feature. labels Mar 4, 2020
// authentication.
type KeychainProvider func() (authn.Keychain, error)

// ImageResolver will attempt to fetch Tekton resources from an OCI compliant image repository.
Copy link
Member Author

Choose a reason for hiding this comment

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

OCIResolver

This partially addresses the desire to fetch tasks
from an OCI image artifact.
Issue: tektoncd#1839

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
@pierretasci
Copy link

/assign vdemeester
/assign sbwsg

@tekton-robot tekton-robot assigned ghost and vdemeester Mar 9, 2020
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/meow

We will need to add more to this, most likely in the form of annotation:

  • support for multiple api (right now it's …v1beta1, at some point we will need to support more than one version at the same time)
  • support for specific version of tekton, or minimum version required

@tekton-robot
Copy link
Collaborator

@vdemeester: cat image

In response to this:

/meow

We will need to add more to this, most likely in the form of annotation:

  • support for multiple api (right now it's …v1beta1, at some point we will need to support more than one version at the same time)
  • support for specific version of tekton, or minimum version required

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 10, 2020

imgRef, err := name.ParseReference(fmt.Sprintf("%s/test/ociresolver", u.Host))
if err != nil {
t.Errorf("undexpected error producing image reference %s", err.Error())
Copy link

Choose a reason for hiding this comment

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

nit: undexpected -> unexpected

type KeychainProvider func() (authn.Keychain, error)

// OCIResolver will attempt to fetch Tekton resources from an OCI compliant image repository.
type OCIResolver struct {
Copy link

Choose a reason for hiding this comment

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

What's a typical usage of this type going to look like? If it's most often going to be instantiated and immediately used like this:

{
  myresolver := remote.OCIResolver{imageRef, kp}
  mytask := myresolver.GetTask(foo)
}

then I suggest simply exposing a GetOCITask func that takes (imageReference string, keychainProvider KeychainProvider, taskName string). WDYT?

Choose a reason for hiding this comment

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

yeah that makes a ton of sense. I guess it comes down to how this evolves when we add a resolver for Git or other remote sources. I could see an argument for either route.

I think the idea here is that it might be easier for a reconciler to use a factory to instantiate a Resolver and call it instead of having to know itself whether it should use an OCIResolver or a GitResolver or whatever else we add. We might even add a "local" resolver and embed the local task resolver into this format. Could be overkill or could be a nice abstraction. Thoughts?

Copy link

Choose a reason for hiding this comment

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

I can definitely see a factory fitting that use case. I'm not sure it follows that we'd therefore need a remote.Resolver interface and creation of structs like this anywhere outside the factory's internals though.

I think it'll ultimately depend on both the kind of configuration we expect to be available and the signature we want to expose for resolution. Examples of config might be that we allow specific resolvers to be turned on/off/configured via configmap / cli flags. Examples of public signature might be a func like ResolveTaskFromRef(taskRef) that figures out the kind of resolution it needs to make without publicly exposing the Resolver type.

Not to say we need to commit to those kinds of design choices here, more that by introducing the Resolver machinery before we get to that stage we're already kind of leaning towards a design. And as often happens we might end up needing to unwind those kinds of choices based on work discovered as we dig into that stage more thoroughly. And in turn that can lead to a some extra work reviewing in future as well.

None of this is a blocker at all from my POV, just raising it from my read-through. 👍

/lgtm

Choose a reason for hiding this comment

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

Yup. Makes a ton of sense. We can always wrap the resolver in a function like you mention to give a single interface to caller but I guess the next PR that embeds this in the reconciler will show if it makes it more or less "gross" and we can go from there 😄

@pierretasci
Copy link

  • support for multiple api (right now it's …v1beta1, at some point we will need to support more than one version at the same time)
  • support for specific version of tekton, or minimum version required

Question for @vdemeester, do you mean that the user should specify a min-supported version of Tekton when referencing the task as in

taskRef:
  name: my-task
  image: docker.com/my-image
  minVersion: v1alpha1

or do you mean that we should ensure the version of the fetched task is not incompatible with the version of the taskrun or pipelinerun that references it?

apiVersion: v1beta1
...
taskRef:
  name: my-task
  image: docker.com/my-image # apiVersion: v1alpha1

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 10, 2020
@tekton-robot tekton-robot merged commit 9e8e752 into tektoncd:master Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit kind/design Categorizes issue or PR as related to design. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants