-
Notifications
You must be signed in to change notification settings - Fork 49
Require leader election for CertRotator and webhook cache #490
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -173,7 +173,7 @@ func AddRotator(mgr manager.Manager, cr *CertRotator) error { | |||||
| secretKey: cr.SecretKey, | ||||||
| wasCAInjected: cr.wasCAInjected, | ||||||
| webhooks: cr.Webhooks, | ||||||
| needLeaderElection: cr.RequireLeaderElection, | ||||||
| needLeaderElection: true, | ||||||
| refreshCertIfNeededDelegate: cr.refreshCertIfNeeded, | ||||||
| fieldOwner: cr.FieldOwner, | ||||||
| certsMounted: cr.certsMounted, | ||||||
|
|
@@ -208,9 +208,8 @@ func addNamespacedCache(mgr manager.Manager, cr *CertRotator, namespace string) | |||||
| if err != nil { | ||||||
| return nil, err | ||||||
| } | ||||||
| // Wrapping the cache to make sure it's also started when the manager | ||||||
| // hasn't been leader elected and CertRotator.RequireLeaderElection is false. | ||||||
| if err := mgr.Add(&cacheWrapper{Cache: c, needLeaderElection: cr.RequireLeaderElection}); err != nil { | ||||||
| // Wrapping the cache so the manager can gate startup on leader election. | ||||||
| if err := mgr.Add(&cacheWrapper{Cache: c, needLeaderElection: true}); err != nil { | ||||||
| return nil, fmt.Errorf("registering namespaced cache: %w", err) | ||||||
| } | ||||||
| return c, nil | ||||||
|
|
@@ -239,8 +238,8 @@ type CertRotator struct { | |||||
| FieldOwner string | ||||||
| RestartOnSecretRefresh bool | ||||||
| ExtKeyUsages *[]x509.ExtKeyUsage | ||||||
| // RequireLeaderElection should be set to true if the CertRotator needs to | ||||||
| // be run in the leader election mode. | ||||||
| // RequireLeaderElection is deprecated and ignored. | ||||||
|
||||||
| // RequireLeaderElection is deprecated and ignored. | |
| // Deprecated: RequireLeaderElection is ignored. |
Copilot
AI
Apr 9, 2026
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.
Leader-election behavior is being changed here (the rotator now always returns true). Given pkg/rotator already has a substantial test suite, it would be good to add a unit test that asserts NeedLeaderElection() is true regardless of RequireLeaderElection’s value, to prevent regressions back to the unsafe default.
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.
After hardcoding
needLeaderElection: true, thecr *CertRotatorparameter is no longer used inaddNamespacedCache, which will cause a Go compile error (cr declared but not used). Consider removing thecrparameter fromaddNamespacedCache(and updating its call sites) or renaming it to_if you need to keep the signature temporarily.