-
Notifications
You must be signed in to change notification settings - Fork 183
NO-JIRA: certregenerationcontroller: Improve goroutine mgmt #1981
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: main
Are you sure you want to change the base?
Conversation
Use sync.WaitGroup to manage goroutines.
|
@tchap: This pull request explicitly references no jira issue. DetailsIn response to this:
Instructions 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 openshift-eng/jira-lifecycle-plugin repository. |
WalkthroughThe changes introduce synchronization primitives (WaitGroup) and context-aware lifecycle management to the certificate regeneration controller. A work queue type is refactored to use typed generics, and graceful shutdown mechanisms are added to ensure proper goroutine coordination and context cancellation handling across multiple controller components. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tchap 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 |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/cmd/certregenerationcontroller/cmd.go (1)
127-127: Minor: DuplicateconfigInformers.Start()call.
configInformers.Start(ctx.Done())is called at line 127 and again at line 168. WhileSharedInformerFactory.Start()is idempotent (safe to call multiple times), the first call could be removed since line 168 starts all informers after resources are set up.- configInformers.Start(ctx.Done()) - wg.Add(1) go func() { defer wg.Done() featureGateAccessor.Run(ctx) }()Also applies to: 168-168
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (2)
pkg/cmd/certregenerationcontroller/cabundlesyncer.go(4 hunks)pkg/cmd/certregenerationcontroller/cmd.go(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
pkg/cmd/certregenerationcontroller/cabundlesyncer.gopkg/cmd/certregenerationcontroller/cmd.go
🔇 Additional comments (4)
pkg/cmd/certregenerationcontroller/cabundlesyncer.go (2)
40-40: LGTM! Correct migration to typed queue.The refactor from the deprecated
RateLimitingInterfacetoTypedRateLimitingInterface[string]is properly implemented with the corresponding constructor and config changes.Also applies to: 52-57
82-105: LGTM! Well-structured goroutine lifecycle management.The shutdown sequence is correct:
c.queue.ShutDown()signals the worker to exit (causesGet()to returnquit=true)wg.Wait()ensures the worker completes before returningThe
HandleCrashWithContext(ctx)is a good improvement for context-aware crash handling.pkg/cmd/certregenerationcontroller/cmd.go (2)
121-133: LGTM! Correct defer ordering for graceful shutdown.The pattern is correct:
defer cancel()afterdefer wg.Wait()ensures cancel executes first (LIFO), signaling goroutines to stop before waiting. The comment at line 123 accurately documents this requirement.
170-180: LGTM! Proper WaitGroup tracking for controller goroutines.Both controller goroutines are correctly managed with
wg.Add(1)before launch anddefer wg.Done()inside, ensuring graceful shutdown coordination.
|
@tchap: The following test failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
Also use typed queues, the untyped are deprecated.
This is just refactoring and handling some todos.
I took the same approach as implemented in core k8s controllers.