Decouple conversion webhook registration from leader election#678
Open
sergenyalcin wants to merge 1 commit into
Open
Decouple conversion webhook registration from leader election#678sergenyalcin wants to merge 1 commit into
sergenyalcin wants to merge 1 commit into
Conversation
Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
Conversion webhook registration was accidentally gated behind leader election through the
SetupGated/gate mechanism.SetupGatedstores a closure that only fires on the elected leader, so follower pods never calledctrl.NewWebhookManagedByand their webhook servers returned 404 for every conversion request. With two replicas and--leader-election, some conversion webhook calls fail.The fix separates webhook registration from reconciler setup:
controller.go.tmpl: addsSetupWebhookWithManager— a standalone function that registers the conversion webhook for a single resource kind. Removes theif o.StartWebhooks { ... }block fromSetup; webhook registration is no longer the reconciler's responsibility.setup.go.tmpl: adds theSetupWebhookWithManager{{ .Group }}aggregator, following the same pattern asSetup{{ .Group }}andSetupGated{{ .Group }}, so providers can register all webhooks for a group in a single call.Providers call
SetupWebhookWithManager_<group>once beforemgr.Start()on every pod, independent of the gate and leader election. Reconciler setup remains behind the gate and runs only on the leader.See the generated provider with these changes: crossplane-contrib/provider-upjet-gcp#953 and crossplane-contrib/provider-upjet-aws#2122
I have:
make reviewableto ensure this PR is ready for review.backport release-x.ylabels to auto-backport this PR if necessary.How has this code been tested
Tested locally by sending webhook calls to the webhook handlers.