-
Notifications
You must be signed in to change notification settings - Fork 417
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
Migrate to using generated reconcilers #733
Conversation
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
/test pull-tekton-triggers-integration-tests |
/hold Two potential issues:
|
|
||
// Don't modify the informer's copy | ||
el := original.DeepCopy() | ||
func (r *Reconciler) ReconcileKind(ctx context.Context, el *v1alpha1.EventListener) pkgreconciler.Event { | ||
// Initial reconciliation | ||
if equality.Semantic.DeepEqual(el.Status, v1alpha1.EventListenerStatus{}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will never happen with the genreconciler, there is a pre-step (you can opt out) that will call InitializeConditions for you and it marks the generation after you return. It also will expose an error if you reconcile and do nothing (you need to call a mark method)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I was following the generated stub: https://github.com/tektoncd/triggers/pull/733/files#diff-2518496f4b5a085db3dc51c69af781c2R52
Is there a newer version which calls the IntializeConditions? (This is the older version of genreconciler I think, before leader elections etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. calling InitializeConditions in the ReconcileKind each time now
}, | ||
}, | ||
} | ||
existingService, err := c.KubeClientSet.CoreV1().Services(el.Namespace).Get(el.Status.Configuration.GeneratedResourceName, metav1.GetOptions{}) | ||
existingService, err := r.KubeClientSet.CoreV1().Services(el.Namespace).Get(el.Status.Configuration.GeneratedResourceName, metav1.GetOptions{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a direct api call, you likely want to avoid doing this and use a lister and informer instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
/hold cancel |
The following is the coverage report on the affected files.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good to me 👍
I have few minor comments
@@ -4,6 +4,7 @@ run: | |||
skip-dirs: | |||
- vendor | |||
- pkg/client/clientset/(.*)/fake | |||
- pkg/client/injection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to skip only injection
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, so injection contains generated code container boilerplate for the reconciler. There were some lint errors I think that was causing the build tests to fail. It doesn't really make sense to fix generated code since it will be overwritten the next time we generate the code so I marked it as ignored from the linter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right i totally agree with you.
One more point is along with injection
i see most of the code from pkg/client
contains generated code so is that okay if we skip all like pipeline
https://github.com/tektoncd/pipeline/blob/master/.golangci.yml#L33 so that it gives clear information why we are skipping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question: So pkg/client is mostly generated code but one folder is not: https://github.com/tektoncd/triggers/tree/master/pkg/client/dynamic/clientset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see the will leave the way you did 👍
TriggersClientSet triggersclientset.Interface | ||
|
||
// CachingClientSet allows us to instantiate Image objects | ||
CachingClientSet cachingclientset.Interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any usage of CachingClientSet
can we remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch :) I think this is a left over from copying over from the Pipelines controller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out removing this also removes some dependencies on knative/pkg/caching!
Using genreconciler from knative/pkg should reduce the amount of boilerplate we need to write a reconciler. * Migrates the logic for deleting logging config maps to a finalizer * Uses listers to get existing deployment, service, configMap instead of making direct API calls. Fixes tektoncd#635 Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
The following is the coverage report on the affected files.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! One minor comment.
/lgtm
c.Logger.Info("Setting up event handlers") | ||
impl := eventlistenerreconciler.NewImpl(ctx, c, func(impl *controller.Impl) controller.Options { | ||
return controller.Options{ | ||
AgentName: ControllerName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Knative docs are a bit unclear here- is this the HTTP user agent that's used? If so, should we make this a little bit more specific so we can ID specific event listeners (e.g. incl namespace/EL name?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used by EventRecorder for EventSource's Component field: https://github.com/knative/eventing/blob/a7223d8e9ec421e92e13da952fe18884ab8ee749/vendor/k8s.io/api/core/v1/types.go#L5057
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is just for the controller and not the actual HTTP agent name for the sinks.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: khrm 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 |
Changes
Using genreconciler from knative/pkg should reduce the amount of boilerplate we
need to write a reconciler. One change I had to make to use genreconciler
is to add a Finalizer for deleting the logging config maps when an
EventListener is deleted.
Fixes #635
/kind misc
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