-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Take advantage of kmeta.OwnerRefable
.
#4110
Conversation
I noticed that the tekton `controller.go` files were inconsistently using `controller.HandleAll` (cosmetic), but also that several of the `impl.EnqueueControllerOf` lines in the PipelineRun controller weren't filtering on the kind of the owner (can cause unnecessary reconciliation). For the latter, we also introduced a nice new helper `controller.FilterController(&v1beta1.TaskRun)` that takes advantage of `kmeta.OwnerRefable` to filter on the GVK in the owner reference. This spiraled a bit because it turns out Tekton wasn't taking advantage of `kmeta.OwnerRefable` or `kmeta.NewControllerRef`! So the majority of the churn in this change is: - `GetOwnerReference` -> `GetGroupVersionKind` (implements `kmeta.OwnerRefable`) - `foo.GetOwnerReference()` -> `*kmeta.NewControllerRef(foo)` As some background, our `kmeta.NewControllerRef` API was modeled after this from API machinery: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#NewControllerRef We added our own variant to drop the tedious GVK requirement, since the first argument should be sufficient (thus `kmeta.OwnerRefable`). /kind cleanup
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
Thanks for this cleanup!
For my own edification: Can you clarify what kinds of unnecessary reconciliations we might have experienced previously, that will be avoided with this new version?
Absolutely. So one of the byproducts of how this was written before (unfiltered) the So if I have a
|
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dlorenc 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
I noticed that the tekton
controller.go
files were inconsistently usingcontroller.HandleAll
(cosmetic), but also that several of theimpl.EnqueueControllerOf
lines in the PipelineRun controller weren't filtering on the kind of the owner (can cause unnecessary reconciliation).For the latter, we also introduced a nice new helper
controller.FilterController(&v1beta1.TaskRun)
that takes advantage ofkmeta.OwnerRefable
to filter on the GVK in the owner reference.This spiraled a bit because it turns out Tekton wasn't taking advantage of
kmeta.OwnerRefable
orkmeta.NewControllerRef
! So the majority of the churn in this change is:GetOwnerReference
->GetGroupVersionKind
(implementskmeta.OwnerRefable
)foo.GetOwnerReference()
->*kmeta.NewControllerRef(foo)
As some background, our
kmeta.NewControllerRef
API was modeled after this from API machinery: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#NewControllerRefWe added our own variant to drop the tedious GVK requirement, since the first argument should be sufficient (thus
kmeta.OwnerRefable
)./kind cleanup
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
Release Notes
cc @dlorenc @imjasonh @vdemeester @afrittoli