Skip to content

Reconcile EventTypes within Source Duck controller #2770

Merged
knative-prow-robot merged 14 commits into
knative:masterfrom
nachocano:rt_registry
Mar 21, 2020
Merged

Reconcile EventTypes within Source Duck controller #2770
knative-prow-robot merged 14 commits into
knative:masterfrom
nachocano:rt_registry

Conversation

@nachocano
Copy link
Copy Markdown
Contributor

@nachocano nachocano commented Mar 17, 2020

Fixes #2484

Proposed Changes

  • 🧽Creating a Source CRD reconciler that reconciles CRDs with the duck.knative.dev/source="true" label. This reconciler is in charge of dynamically creating controllers for a particular GVR.

  • 🧽Creating a Source duck reconciler, which is dynamically created by the CRD one mentioned above, that reconciles duckv1.Source resources with a particular GVR. It currently creates their EventTypes but in the future it can do more things.

  • In order to do this I needed to change the duckv1.SourceStatus to also contain a CloudEventAttributes list. This might be the most controversial change and I'm fully open for feedback. I couldn't just set the ceSource in the Status, because different Sources do different things. For example, the GithubSource allows you to select a subset of the eventTypes listed in the CRD (thus we need the ceTypes information as well and cannot just rely on the CRD registry annotation). The KafkaSource may contain multiple ceSources, e.g., if you specify two topics then the data plane constructs the ceSource based on the msg.Topic. In some Google Sources, we do not event know the ceSource at control-plane time, but rather on the data plane (thus I made eventType.spec.source optional), etc. To have a better idea of what I'm talking about, please refer Removing EventType dependency from eventing-contrib eventing-contrib#1036 in eventing-contrib. Also, here is the pkg PR Updating duckv1.SourceStatus to include CloudEventAttributes pkg#1165

  • Added some TODOs in the code so that they are properly revisited once we address Improve EventType Registry #2750. IMO these changes puts us in a much better position for revisiting EventType. Also I made some mandatory parameters from EventType optional as well (not breaking change).

  • Added E2E tests for both ApiServerSource and PingSource.

  • Still missing some UTs, planning on adding them in a follow up...

Ack to @n3wscott for his autotrigger and discovery magic. This is basically the former.

Release Note


Docs

/assign @lionelvillard @vaikas @n3wscott @mattmoor @mikehelmick would be great to have your input

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@nachocano: GitHub didn't allow me to assign the following users: would, to, your, input, be, great, have.

Note that only knative members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

Details

In response to this:

Fixes #2484

Proposed Changes

  • 🧽Creating a Source CRD reconciler that reconciles CRDs with the duck.knative.dev/source="true" label. This reconciler is in charge of dynamically creating controllers for a particular GVR.

  • 🧽Creating a Source duck reconciler, which is dynamically created by the CRD one mentioned above, that reconciles duckv1.Source resources with a particular GVR. It currently creates their EventTypes but in the future it can do more things.

  • In order to do this I needed to change the duckv1.SourceStatus to also contain a CloudEventAttributes list. This might be the most controversial change and I'm fully open for feedback. I couldn't just set the ceSource in the Status, because different Sources do different things. For example, the GithubSource allows you to select a subset of the eventTypes listed in the CRD (thus we need the ceTypes information as well and cannot just rely on the CRD registry annotation). The KafkaSource may contain multiple ceSources, e.g., if you specify two topics then the data plane constructs the ceSource based on the msg.Topic. In some Google Sources, we do not event know the ceSource at control-plane time, but rather on the data plane (thus I made eventType.spec.source optional), etc. To have a better idea of what I'm talking about, please refer Removing EventType dependency from eventing-contrib eventing-contrib#1036 in eventing-contrib.

  • Added some TODOs in the code so that they are properly revisited once we address Improve EventType Registry #2750. IMO these changes puts us in a much better position for revisiting EventType. Also I made some mandatory parameters from EventType optional as well (not breaking change).

  • Still missing: UTs, but who needs that :)

Ack to @n3wscott for his autotrigger and discovery magic. This is basically the former.

Release Note


Docs

/assign @lionelvillard @vaikas @n3wscott would be great to have your input

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.

@knative-prow-robot knative-prow-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 17, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 17, 2020
@knative-prow-robot knative-prow-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 17, 2020
Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 17, 2020
Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@nachocano
Copy link
Copy Markdown
Contributor Author

ping...
It would be great to get some feedback on this.
I'm going on paternity leave end of next week, and will be gone for 1.5 months. So if we can get this in before that, it'd be great. Especially because it cleans up a bunch of things in eventing-contrib. See knative/eventing-contrib#1036 and IMO puts us in a better position to addressing EventType improvements

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 19, 2020
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 20, 2020
Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Comment thread pkg/reconciler/source/duck/controller.go
Comment thread pkg/reconciler/source/duck/resources/eventtype.go Outdated
Comment thread config/core/roles/controller-clusterroles.yaml Outdated
Comment thread pkg/apis/eventing/register.go
Comment thread pkg/reconciler/apiserversource/apiserversource.go
Comment thread pkg/apis/sources/v1alpha1/apiserver_types.go
Comment thread pkg/reconciler/source/crd/crd.go Outdated
Comment thread pkg/reconciler/source/crd/crd.go Outdated
Comment thread pkg/reconciler/source/crd/crd.go
Comment thread pkg/reconciler/source/crd/crd.go
Comment thread pkg/reconciler/source/crd/crd.go Outdated
@n3wscott
Copy link
Copy Markdown
Contributor

Two changes I would like to see:

  1. Drop the finalizers on the CRDs, there is no need.
  2. Add a e2e test or two for this to confirm it works.

@nachocano
Copy link
Copy Markdown
Contributor Author

2. confirm it works.

OK, will do! Thanks for reviewing Scott!

@knative-prow-robot knative-prow-robot added the area/test-and-release Test infrastructure, tests or release label Mar 20, 2020
@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/eventtype_validation.go 95.0% 92.3% -2.7
pkg/apis/eventing/v1beta1/eventtype_validation.go 95.0% 92.3% -2.7
pkg/apis/sources/v1alpha1/apiserver_lifecycle.go 59.3% 56.0% -3.3
pkg/apis/sources/v1alpha1/ping_lifecycle.go 85.7% 84.2% -1.5
pkg/reconciler/apiserversource/apiserversource.go 79.1% 80.2% 1.1
pkg/reconciler/apiserversource/controller.go 94.1% 93.3% -0.8
pkg/reconciler/pingsource/controller/pingsource.go 63.9% 64.0% 0.1

@nachocano nachocano changed the title [WIP] Reconcile EventTypes within Source Duck controller Reconcile EventTypes within Source Duck controller Mar 20, 2020
@knative-prow-robot knative-prow-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 20, 2020
@nachocano
Copy link
Copy Markdown
Contributor Author

Changes done, RFAL

@n3wscott
Copy link
Copy Markdown
Contributor

nice work, looks real good. This will clean up a lot of controllers. 👍

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 21, 2020
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: n3wscott, nachocano

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

The pull request process is described here

Details 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

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. area/test-and-release Test infrastructure, tests or release cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. 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.

EventTypes should be registered by the EventType controller only

8 participants