Skip to content

fix(store): ensure CR reflectors stop on context cancellation#2870

Open
mrueg wants to merge 1 commit intokubernetes:mainfrom
mrueg:fix-leaks
Open

fix(store): ensure CR reflectors stop on context cancellation#2870
mrueg wants to merge 1 commit intokubernetes:mainfrom
mrueg:fix-leaks

Conversation

@mrueg
Copy link
Copy Markdown
Member

@mrueg mrueg commented Feb 7, 2026

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 #

…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.
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 7, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

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 kubernetes-sigs/prow repository.

@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG Instrumentation Feb 7, 2026
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants