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

Add a CRD for Interceptors #921

Closed
wants to merge 4 commits into from
Closed

Add a CRD for Interceptors #921

wants to merge 4 commits into from

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Jan 22, 2021

Changes

Broken down into 2 commits for easier review:

  1. Add Interceptor CRD type
    The spec currently only contains a URL field to locate where the interceptor
    is running. Other fields will be added as they are implemented in follow ups.

  2. Migrate core interceptors to use Interceptor CRD

    1. Add YAML definitions for each core interceptor using the Interceptor CRD.
    2. Modify the EventListener to use the Interceptor CRD to find the Interceptor's URL.
    3. Update roles/RBAC/unit tests for the above 2 changes.
  3. Fix core interceptors installation errors
    We need to wait for the Interceptors CRD to become established before we can
    create the core interceptors. Otherwise, we run the risk of trying to create
    the core-interceptors too early leading to installation errors.

Submitter Checklist

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

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Release Notes

Adds a new CRD type called Interceptors for installing pluggable interceptors. Moves current set of core-inerceptors to be installed using the new CRD.

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jan 22, 2021
@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign dibyom
You can assign the PR to them by writing /assign @dibyom in a comment when ready.

The full list of commands accepted by this bot can be found 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 22, 2021
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/interceptors.go 92.1% 91.6% -0.5
pkg/sink/sink.go 78.4% 77.1% -1.3
test/controller.go 73.1% 71.4% -1.7

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2021
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2021
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/interceptors.go 92.1% 91.6% -0.5
pkg/sink/sink.go 78.4% 77.1% -1.3
test/controller.go 73.1% 71.4% -1.7

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/interceptors.go 92.1% 91.6% -0.5
pkg/sink/sink.go 78.4% 77.1% -1.3
test/controller.go 73.1% 71.4% -1.7

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/interceptors.go 92.1% 91.6% -0.5
pkg/sink/sink.go 78.4% 77.1% -1.3
test/controller.go 73.1% 71.4% -1.7

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/interceptors.go 92.1% 91.6% -0.5
pkg/sink/sink.go 78.4% 77.1% -1.3
test/controller.go 73.1% 71.4% -1.7

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/interceptors.go 92.1% 91.6% -0.5
pkg/sink/sink.go 78.4% 77.1% -1.3
test/controller.go 73.1% 71.4% -1.7

@dibyom dibyom marked this pull request as ready for review January 29, 2021 15:50
@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 Jan 29, 2021
@dibyom
Copy link
Member Author

dibyom commented Jan 29, 2021

/assign @wlynch

@dibyom
Copy link
Member Author

dibyom commented Jan 29, 2021

/cc @bigkevmcd

name: cel
spec:
clientConfig:
url: "http://tekton-triggers-core-interceptors.tekton-pipelines.svc/cel"
Copy link
Member

Choose a reason for hiding this comment

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

Letting the users set the path definitely seems useful, but it's unclear to me how users would know what Service URL this would be associated with, particularly if there are multiple interceptor services at play.

Few ideas:

  1. Is the full URL something we can expose in the status and let the Interceptor controller handle filling this in for clients?
  2. Should these CRDs be produced by Interceptor providers instead (e.g. on startup/control loop)? This has the added benefit of not requiring users to apply the interceptors themselves, sidestepping the apply ordering issues.

Copy link
Member Author

Choose a reason for hiding this comment

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

end users do not have to know what the URL is. Only the interceptor provider. I implemented url first since that's the simplest but we will support a ref to an object too .

Is the full URL something we can expose in the status and let the Interceptor controller handle filling this in for clients?

Yes, was planning on adding this as part of the followup that adds service ref support. That being said, it might still make sense to have the same URL resolution happen at the EL level in case the EL receives an event before the Interceptor controller does a reconcile loop.

Should these CRDs be produced by Interceptor providers instead (e.g. on startup/control loop)? This has the added benefit of not requiring users to apply the interceptors themselves, sidestepping the apply ordering issues.

Interesting idea. Maybe? I think it will solve the issue only for the core interceptors that are bundled with the Triggers installation. Otherwise, it will be up to the interceptor provider to ship both the deployment running the logic and the CRD to go with it. They could decide to ship a deployment that creates the CRD on startup (but then that deployment will need to have RBAC roles to create Interceptors)

Copy link
Member

Choose a reason for hiding this comment

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

but then that deployment will need to have RBAC roles to create Interceptors

mmmmm good point. Perhaps this is better then.

Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

/lgtm

Holding off on approval - I think it'd be useful to get a 2nd pair of eyes on this as a sanity check to validate the "user" (interceptor author?) facing API.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 1, 2021
Copy link
Member

@bigkevmcd bigkevmcd left a comment

Choose a reason for hiding this comment

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

I think we should improve that error message in the event of not found.

pkg/interceptors/interceptors.go Outdated Show resolved Hide resolved
pkg/interceptors/interceptors.go Outdated Show resolved Hide resolved
pkg/interceptors/interceptors_test.go Outdated Show resolved Hide resolved
This commit adds the Interceptor CRD type as defined in TEP.
The `spec` currently only contains a URL field to locate where the interceptor
is running. Other fields will be added as they are implemented in follow ups.

Part of tektoncd#868

Signed-off-by: Dibyo Mukherjee <[email protected]>
This commit does the following:
1. Add YAML definitions for each core interceptor using the Interceptor CRD.
2. Modify the EventListener to use the Interceptor CRD to find the Interceptor's URL.
3. Update roles/RBAC/unit tests for the above 2 changes.

Fixes tektoncd#868

Signed-off-by: Dibyo Mukherjee <[email protected]>
We need to wait for the Interceptors CRD to become established before we can
create the core interceptors. Otherwise, we run the risk of trying to create
the core-interceptors too early leading to installation errors.

Signed-off-by: Dibyo Mukherjee <[email protected]>
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 4, 2021
@tekton-robot
Copy link

New changes are detected. LGTM label has been removed.

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/interceptors.go 92.1% 91.6% -0.5
pkg/sink/sink.go 78.4% 77.1% -1.3
test/controller.go 73.1% 71.4% -1.7

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/interceptors.go 92.1% 91.6% -0.5
pkg/sink/sink.go 78.4% 77.1% -1.3
test/controller.go 73.1% 71.4% -1.7

Copy link
Contributor

@savitaashture savitaashture left a comment

Choose a reason for hiding this comment

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

few nits

pkg/interceptors/interceptors.go Show resolved Hide resolved
docs/interceptors.md Show resolved Hide resolved
config/interceptors/core-interceptors.yaml Show resolved Hide resolved
config/300-interceptor.yaml Show resolved Hide resolved
@savitaashture
Copy link
Contributor

@dibyom

ko apply -f config/ won't read interceptors folder
So we may

OR

We can create a symlink for the files present in interceptors folder

Copy link
Member

@MarcelMue MarcelMue left a comment

Choose a reason for hiding this comment

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

Some minor comments.

plural: interceptors
singular: interceptor
shortNames:
- i
Copy link
Member

Choose a reason for hiding this comment

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

I personally don't think this shortname is a good idea. I would prefer having none than a 1 character one.

Copy link
Member Author

Choose a reason for hiding this comment

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

fair enough. I am also thinking of renaming the actual type from Interceptors to InterceptorType to make it clearer that this CR defines a new "type" or kind of interceptor that can then be used by a end user.

apiVersion: triggers.tekton.dev/v1alpha1
kind: Interceptor
metadata:
name: cel
Copy link
Member

Choose a reason for hiding this comment

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

Putting them in namespace tekton-pipelines would make sense to me. This is where basically everything else is, right? Especially since they are shipped together.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right now this is a cluster wide type i.e. you install the InterceptorType GitHub for your entire cluster. Similar to how you install pipelines for the entire cluster.

metadata:
name: cel
spec:
clientConfig:
Copy link
Member

Choose a reason for hiding this comment

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

WDYT about omitting Config from the name and simply naming the field client?
Every CR is config to an extend and it's clear that this simply defines the client which handles the interceptor.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was basing this off of the webhook client config type that k8s webhook types : https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#webhookclientconfig-v1-admissionregistration-k8s-io

On second thought, maybe I can just use that type itself instead of defining my own type for this.


Spec InterceptorSpec `json:"spec"`
}

Copy link
Member

Choose a reason for hiding this comment

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

Godoc should be added.

name: bitbucket
spec:
clientConfig:
url: "http://tekton-triggers-core-interceptors.tekton-pipelines.svc/bitbucket"
Copy link
Contributor

Choose a reason for hiding this comment

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

just thinking at high level

These interceptors are core interceptors which will be installed as part of triggers installation what if Tekton installs in different namespace other than tekton-pipelines 🤔

In that case will this be responsibility of user/admin who installs Triggers ?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah this is a bit confusing right now. The idea is instead of url we'd also support a service field that contains a reference to the service for the deployed core interceptors. Custom installs would have to change the namespace of the service but would not have to modify a URL.

(I was thinking of adding that as a separate PR but maybe I'll add it to this one itself to make it less confusing).

@dibyom
Copy link
Member Author

dibyom commented Feb 10, 2021

/hold

I'm going to split this into a couple of different PRs

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 12, 2021
@tekton-robot
Copy link

@dibyom: PR needs rebase.

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.

@dibyom
Copy link
Member Author

dibyom commented Feb 26, 2021

/close

Closing in favor of #960 and #976

@tekton-robot
Copy link

@dibyom: Closed this PR.

In response to this:

/close

Closing in favor of #960 and #976

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants