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

Use knative "adapter" to simplify event listener sink #1207

Merged
merged 4 commits into from
Sep 8, 2021

Conversation

mattmoor
Copy link
Member

@mattmoor mattmoor commented Aug 29, 2021

/kind cleanup

This simplifies the event listener sink by adopting the knative eventing "adapter" library, which is like our sharedmain for controlplanes, but for the eventing dataplane components. This pattern passes config data as JSON in env:, so it also dramatically simplifies the controller logic because we no longer need to copy around empty configmaps and clean them up, and net removes a lot of code.

This also takes advantage of the new dynamic client injection logic to reduce the overhead of each adapter on the API server, and potentially dramatically improves cold start time of ksvc based sinks (they no longer need to sync informers to handle traffic). If this proves troublesome, it should be relatively straightforward to switch things back.

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

Adopt knative eventing adapter for event listener sink.
Change the way event listeners are configured to drop per-namespace configmaps.

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Aug 29, 2021
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 29, 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/reconciler/eventlistener/eventlistener.go 69.8% 67.2% -2.6
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2

@mattmoor
Copy link
Member Author

Ha, it looks like this is actually consumed, by a little function in pkg/logging within triggers, so:

/hold

I may try to expand this PR to drop the config-logging propagation altogether, since we can probably get away with env/flags and it will greatly simplify the mechanics of EventListener.

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 29, 2021
@mattmoor mattmoor changed the title Drop config-logging volume [WIP] Drop config-logging volume Aug 29, 2021
@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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 29, 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/reconciler/eventlistener/eventlistener.go 69.8% 67.9% -2.0
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2
test/controller.go 71.1% 71.7% 0.6

@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/reconciler/eventlistener/eventlistener.go 69.8% 67.2% -2.6
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2
test/controller.go 71.1% 71.7% 0.6

@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/reconciler/eventlistener/eventlistener.go 69.8% 67.2% -2.6
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2
test/controller.go 71.1% 71.7% 0.6

@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/reconciler/eventlistener/eventlistener.go 69.8% 67.2% -2.6
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2
test/controller.go 71.1% 71.7% 0.6

@mattmoor
Copy link
Member Author

/retest

@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/reconciler/eventlistener/eventlistener.go 69.8% 67.8% -2.0
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2
test/controller.go 71.1% 71.7% 0.6

@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/reconciler/eventlistener/eventlistener.go 69.8% 67.8% -2.0
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2
test/controller.go 71.1% 71.7% 0.6

@mattmoor
Copy link
Member Author

/retest

1 similar comment
@mattmoor
Copy link
Member Author

/retest

@mattmoor
Copy link
Member Author

The v1alpha1/github example keeps failing, but I think there is a race because I definitely see the pods for the task here in the post-failure dump 🤔

default            pod/github-run-7hfb6-pod-lp7qm                                       0/2     Init:0/2          0          1s

Adding a sleep to see if that helps...

@tekton-robot
Copy link

@n3wscott: changing LGTM is restricted to collaborators

In response to this:

/LGTM

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.

cmd/eventlistenersink/main.go Show resolved Hide resolved
@@ -25,5 +32,15 @@ func WithClient(client dynamic.Interface) clientset.Option {
cs.Add(r, client)
}
}
for version, resources := range allowedTriggersTypes {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need TriggersType here? @dibyom

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 is needed to pass now, since everything is going over the dynamic client now.

Copy link
Member

@dibyom dibyom Sep 7, 2021

Choose a reason for hiding this comment

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

If everything is going over the dynamic client now, can we get rid of the typed clientsets in the Sink struct?

https://github.com/tektoncd/triggers/blob/main/pkg/sink/sink.go#L50-L51

@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/reconciler/eventlistener/eventlistener.go 68.0% 69.5% 1.5
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2

@mattmoor
Copy link
Member Author

mattmoor commented Sep 2, 2021

/hold cancel
/assign @dibyom

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 2, 2021
Copy link
Member

@dibyom dibyom left a comment

Choose a reason for hiding this comment

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

Thanks @mattmoor ! The EL initialization code looks much simpler!

I'm like halfway through this PR at the moment and will try this out on my local setup.
Are there any docs around the eventing adapter library that I can use to understand what it provides better?

Also, it looks like we've added a lott of files to vendor/ Are all of them needed? e.g. I found vendor/k8s.io/client-go/applyconfigurations/networking/v1/networkpolicyport.go etc.

cmd/eventlistenersink/main.go Show resolved Hide resolved
pkg/adapter/adapter.go Show resolved Hide resolved
cmd/eventlistenersink/main.go Show resolved Hide resolved
"v1beta1": {"pipelineruns", "taskruns", "pipelines", "clustertasks", "tasks"},
}
allowedTriggersTypes = map[string][]string{
"v1alpha1": {"clusterinterceptors"},
Copy link
Contributor

@savitaashture savitaashture Sep 6, 2021

Choose a reason for hiding this comment

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

Do we also need to add "clustertriggerbindings", "eventlisteners", "triggerbindings", "triggers", "triggertemplates" here ?
/cc @dibyom

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 can for completeness, but given the way this access control works, it is not needed to pass tests. You only need the exact versions through which the code accesses things.

@mattmoor
Copy link
Member Author

mattmoor commented Sep 6, 2021

Are there any docs around the eventing adapter library that I can use to understand what it provides better?

@n3wscott or @lionelvillard might have a pointer, not sure.

I found vendor/k8s.io/client-go/applyconfigurations/networking/v1/networkpolicyport.go etc

I think this is related to the K8s API adding server-side apply in the latest client update that knative/pkg pulls in.

@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/reconciler/eventlistener/eventlistener.go 67.8% 69.2% 1.4
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2

@lionelvillard
Copy link

Are there any docs around the eventing adapter library that I can use to understand what it provides better?

@n3wscott or @lionelvillard might have a pointer, not sure.

This is a good starting point: https://github.com/knative/eventing/tree/main/docs/source#receive-adapters

@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/reconciler/eventlistener/eventlistener.go 67.8% 69.2% 1.4
pkg/reconciler/eventlistener/resources/custom.go 93.9% 93.8% -0.2

Copy link
Member

@dibyom dibyom left a comment

Choose a reason for hiding this comment

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

Looking good. Could we also get rid of the typed clients now that everything is going over the dynamic clientset?

@@ -90,12 +90,16 @@ port_forward_and_curl() {
exit 1
fi

# Wait a few seconds for resources to show up
sleep 3
Copy link
Member

Choose a reason for hiding this comment

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

we already wait for the EL to be ready in the check_eventlistener function. Do we also need the sleep?

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 is waiting for the EL to materialize the TaskRuns and PipelineRuns before querying them below.

i was seeing intermittent flakes without this.

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom

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 Sep 8, 2021
@mattmoor
Copy link
Member Author

mattmoor commented Sep 8, 2021

Could we also get rid of the typed clients now that everything is going over the dynamic clientset?

The typed clients (and objects) are much nicer to deal with directly, this just tunnels them through the dynamic client.

@dlorenc
Copy link
Contributor

dlorenc commented Sep 8, 2021

/lgtm

Nice!

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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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.

8 participants