fix(store): ensure CR reflectors stop on context cancellation#2870
fix(store): ensure CR reflectors stop on context cancellation#2870mrueg wants to merge 1 commit intokubernetes:mainfrom
Conversation
…ation Previously, custom resource reflectors were only stopped when their specific stop channel in GVKToReflectorStopChanMap was closed (e.g., during discovery updates). If the main application context was cancelled, these reflectors would continue to run, potentially causing leaks. This change wraps the GVK-specific stop channel with a select that also listens to the main application context cancellation, ensuring all CR reflectors are properly shut down when the application exits.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mrueg The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
This issue is currently awaiting triage. If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the The 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. |
What this PR does / why we need it:
Previously, custom resource reflectors were only stopped when their specific stop channel in GVKToReflectorStopChanMap was closed (e.g., during discovery updates). If the main application context was cancelled, these reflectors would continue to run, potentially causing leaks.
This change wraps the GVK-specific stop channel with a select that also listens to the main application context cancellation, ensuring all CR reflectors are properly shut down when the application exits.
How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
Which issue(s) this PR fixes: (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged)Fixes #