Repository navigation
Fix #8994 (approach C): adopt controller-runtime TypedEventHandler - #9006
wallrj-cyberark wants to merge 1 commit into
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions 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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1cb7c63 to
481afef
Compare
Replace cert-manager's custom blockingEventHandler with controller-runtime's handler.TypedFuncs, and change filteredEventHandler to wrap handler.TypedEventHandler[T, types.NamespacedName] instead of cache.ResourceEventHandler. This aligns cert-manager's event handler architecture with controller-runtime's typed handler pattern, where the adapter layer (filteredEventHandler) performs the sole type assertion and all downstream handlers receive fully typed events. Also split AddEventHandler into separate typed and metadata informer registration methods, fixing the log spam described in cert-manager#8994 where a handler typed as *corev1.Secret received *v1.PartialObjectMetadata from the metadata informer. The issuer and clusterissuer controllers register on both informers; certificate sub-controllers register only on the typed informer. Fixes: cert-manager#8994 Signed-off-by: Richard Wall <[email protected]> Co-Authored-By: Claude <[email protected]> Signed-off-by: Richard Wall <[email protected]>
481afef to
f7ad468
Compare
|
Closing this in favour of #9005. Why: #8994 itself is already fixed on This PR's remaining, distinguishing value was the second half: adopting controller-runtime's
None of these are hard blockers on their own, but together they read as "adopt the interface because it looks similar" rather than "adopt controller-runtime's actual reconciliation model", which is where I think the real value would come from. Thoughts on incremental controller-runtime adoption, for whenever there's appetite to revisit this:
Happy to pick this up as a separate proposal once there's a decision on priority — for now, closing to avoid two structurally-overlapping PRs sitting open. |
Summary
Adopt controller-runtime's
handler.TypedEventHandlerfor cert-manager'sinformer event handling, fixing #8994 and aligning with the upstream
pattern.
blockingEventHandler[T]withhandler.TypedFuncs[T, types.NamespacedName]from controller-runtime.filteredEventHandler[T]to wraphandler.TypedEventHandler[T, types.NamespacedName]instead ofcache.ResourceEventHandler. This moves all type assertions into theadapter layer (
filteredEventHandler) and delivers fully typed eventsdownstream — no type casts in work functions.
AddEventHandlerinto separate typed and metadata registrationmethods (same structural fix as approach B).
certificate sub-controllers register only on the typed informer.
This is a stepping stone toward full controller-runtime adoption. The
filteredEventHandleris the cert-manager equivalent ofcontroller-runtime's
internal.EventHandler— it bridges client-goinformers to the typed handler interface.
See also:
All three PRs target
masterfor review and CI; they are mutuallyexclusive approaches to the same issue.
Motivation
#8994 — discovered shortly after the 1.21.0
release. The generics refactor in #8407 changed the handler signature
from
func(interface{})tofunc(U), which broke the dual-informerSecret handler path.
Test plan
go test ./pkg/controller/—TestBlockingEventHandler,TestQueuingEventHandler,TestFilterEventHandler,TestOnlyUpdateWhenResourceChangedall passgo test ./pkg/controller/certificates/...— all passgo test ./pkg/controller/issuers/...— passgo test ./pkg/controller/clusterissuers/...— passgo test ./internal/informers/...— pass