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 EventListener Selector For TriggerCRD #773

Merged
merged 1 commit into from
Nov 20, 2020
Merged

Conversation

khrm
Copy link
Contributor

@khrm khrm commented Sep 28, 2020

Changes

EventListener have NamespaceSelector field which gives us namespaces from where EventListener fetches Trigger object to process events.

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.

Release Notes


Added Namespace Selector field for EventListener which enables EventListener to serve across the namespace. `namespaceSelector` field with `matchNames` need to be provided to enable selector.
`
  namespaceSelector:
    matchNames:
    - nsName1
    - nsName2
`

@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 Sep 28, 2020
@tekton-robot tekton-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 28, 2020
@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/sink/sink.go 76.9% 81.4% 4.5
test/builder/eventlistener.go 81.9% 82.7% 0.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/sink/sink.go 76.9% 81.4% 4.5
test/builder/eventlistener.go 81.9% 82.7% 0.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/sink/sink.go 76.9% 81.4% 4.5
test/builder/eventlistener.go 78.7% 79.6% 0.9

@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/sink/sink.go 76.9% 81.4% 4.5
test/builder/eventlistener.go 78.7% 79.6% 0.9

@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/sink/sink.go 76.9% 81.4% 4.5
test/builder/eventlistener.go 78.7% 79.6% 0.9

@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/sink/sink.go 76.9% 81.4% 4.5
test/builder/eventlistener.go 78.7% 79.6% 0.9

@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/sink/sink.go 76.9% 81.2% 4.4
test/builder/eventlistener.go 78.7% 79.6% 0.9

@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/sink/sink.go 76.9% 75.0% -1.9
test/builder/eventlistener.go 78.7% 79.6% 0.9

@khrm khrm added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 28, 2020
@dibyom dibyom linked an issue Sep 28, 2020 that may be closed by this pull request
pkg/sink/sink.go Outdated Show resolved Hide resolved
// list of namespaces.
// +k8s:openapi-gen=true
type NamespaceSelector struct {
// Boolean describing whether all namespaces are selected in contrast to a
Copy link
Member

Choose a reason for hiding this comment

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

curious about this Any field. Wondering if we need a separate field or we could pass something to MatchNames to indicate we should select all namespaces (e.g. matchNames: ["*"] or matchNames:[""].

Copy link
Member

Choose a reason for hiding this comment

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

AdmissionWebhooks also have NameSpaceSelector (and ObjectSelector). We could take some pointers from there: https://github.com/kubernetes/api/blob/master/admissionregistration/v1beta1/types.go#L410

(might be worth seeing if there are any reusable bits in the implementation that we could use too)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, any here could be dispense with but AdmissionWebhook implementation is for more complex scenarios. https://github.com/kubernetes/api/blob/8519c5ea46199d57724725d5b969c5e8e0533692/admissionregistration/v1beta1/types.go#L372

pkg/sink/sink.go Outdated

var trItems []triggersv1.Trigger
if el.Spec.NamespaceSelector.Any {
trList, err := r.TriggersClient.TriggersV1alpha1().Triggers("").List(metav1.ListOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

might want to use an informer here to reduce calls to the API server. ( can be a follow up though)

@dibyom
Copy link
Member

dibyom commented Oct 6, 2020

@khrm was there additional work you were planning on doing before unmarking this as WIP?

(One thing we should add are some release notes and some docs/examples).

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 8, 2020
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 5, 2020
@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
test/builder/eventlistener.go 78.7% 79.6% 0.9

@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
test/builder/eventlistener.go 78.7% 79.6% 0.9

@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 19, 2020
@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/apis/triggers/v1alpha1/event_listener_validation.go 100.0% 98.8% -1.2
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 78.2% 78.5% 0.3
test/builder/eventlistener.go 78.7% 79.2% 0.4

@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/apis/triggers/v1alpha1/event_listener_validation.go 100.0% 98.8% -1.2
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 78.2% 78.5% 0.3
test/builder/eventlistener.go 78.7% 79.2% 0.4

@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
cmd/triggerrun/cmd/root.go 45.7% 45.2% -0.5
pkg/apis/triggers/v1alpha1/event_listener_validation.go 100.0% 98.8% -1.2
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 78.2% 78.5% 0.3
test/builder/eventlistener.go 78.7% 79.2% 0.4

@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
cmd/triggerrun/cmd/root.go 45.7% 45.2% -0.5
pkg/apis/triggers/v1alpha1/event_listener_validation.go 100.0% 98.8% -1.2
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 78.2% 78.5% 0.3
test/builder/eventlistener.go 78.7% 79.2% 0.4

@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
cmd/triggerrun/cmd/root.go 45.7% 45.2% -0.5
pkg/apis/triggers/v1alpha1/event_listener_validation.go 100.0% 98.8% -1.2
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 78.2% 78.5% 0.3
pkg/sink/sink.go 83.9% 78.9% -5.0
test/builder/eventlistener.go 78.7% 79.2% 0.4

@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
cmd/triggerrun/cmd/root.go 45.7% 45.2% -0.5
pkg/apis/triggers/v1alpha1/event_listener_validation.go 100.0% 98.8% -1.2
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 78.2% 78.5% 0.3
pkg/sink/sink.go 83.9% 78.9% -5.0
test/builder/eventlistener.go 78.7% 79.2% 0.4

@savitaashture
Copy link
Contributor

savitaashture commented Nov 19, 2020

Code looks good to me 👍
@khrm can we add e2e to use trigger with NSSelector?

examples/selectors/03_trigger.yaml Show resolved Hide resolved
examples/selectors/02_eventlistener-sel.yaml Show resolved Hide resolved
pkg/sink/sink_test.go Outdated Show resolved Hide resolved
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2020
@khrm khrm force-pushed the elSel branch 2 times, most recently from 005adb7 to 837e2f5 Compare November 20, 2020 08:36
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2020
@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
cmd/triggerrun/cmd/root.go 45.7% 45.2% -0.5
pkg/apis/triggers/v1alpha1/event_listener_validation.go 100.0% 98.8% -1.2
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 78.2% 78.5% 0.3
pkg/sink/sink.go 83.9% 78.9% -5.0
test/builder/eventlistener.go 78.7% 79.2% 0.4

@khrm
Copy link
Contributor Author

khrm commented Nov 20, 2020

@savitaashture I would create another pr for e2e test after this is merge.

EventListener have NamespaceSelector field which gives us namespaces
from where EventListener fetches Trigger object to process events.
@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
cmd/triggerrun/cmd/root.go 45.7% 45.2% -0.5
pkg/apis/triggers/v1alpha1/event_listener_validation.go 100.0% 98.8% -1.2
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 78.2% 78.5% 0.3
pkg/sink/sink.go 83.9% 78.9% -5.0
test/builder/eventlistener.go 78.7% 79.2% 0.4

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.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 20, 2020
@tekton-robot tekton-robot merged commit 7702dc4 into tektoncd:master Nov 20, 2020
@khrm khrm deleted the elSel branch July 28, 2021 14:26
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EventListener Namespace Selector for Trigger Object
4 participants