Skip to content

fix(metrics-api): use correct label selector in getEndpointsUrlsFromServiceURL#7642

Merged
wozniakjan merged 1 commit into
kedacore:mainfrom
proudier:metrics-api-fix
Apr 11, 2026
Merged

fix(metrics-api): use correct label selector in getEndpointsUrlsFromServiceURL#7642
wozniakjan merged 1 commit into
kedacore:mainfrom
proudier:metrics-api-fix

Conversation

@proudier

@proudier proudier commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Fix the issue described in #7641

Root cause of the issue

labels.NewSelector() creates an empty selector matching everything, and Matches() is read-only — its return value was discarded. This caused KEDA to list all EndpointSlices in the namespace instead of filtering by kubernetes.io/service-name.

Content of this PR

  • Add a unit test that seeds a fake client with two services' EndpointSlices and asserts only the target service's endpoints are returned.
  • Replace with labels.SelectorFromSet() which correctly constrains the selector.

Checklist

  • I have verified that my change is according to the deprecations & breaking changes policy
  • Tests have been added (if applicable)
  • Ensure make generate-scalers-schema has been run to update any outdated generated files
  • Changelog has been updated and is aligned with our changelog requirements, only when the change impacts end users
  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

Fixes #7641

@proudier proudier requested a review from a team as a code owner April 10, 2026 20:46
@keda-automation keda-automation requested a review from a team April 10, 2026 20:46
@github-actions

Copy link
Copy Markdown

Thank you for your contribution! 🙏

Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected.

While you are waiting, make sure to:

  • Add an entry in our changelog in alphabetical order and link related issue
  • Update the documentation, if needed
  • Add unit & e2e tests for your changes
  • GitHub checks are passing
  • Is the DCO check failing? Here is how you can fix DCO issues

Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient.

Learn more about our contribution guide.

@snyk-io

snyk-io Bot commented Apr 10, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@proudier proudier changed the title fix(metrics-api): use correct label selector in aggregateFromKubeServiceEndpoints fix(metrics-api): use correct label selector in getEndpointsUrlsFromServiceURL Apr 10, 2026
@rickbrouwer

rickbrouwer commented Apr 11, 2026

Copy link
Copy Markdown
Member

/run-e2e metrics_api
Update: You can check the progress here

@rickbrouwer rickbrouwer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix!

@rickbrouwer rickbrouwer added the Awaiting/2nd-approval This PR needs one more approval review label Apr 11, 2026
@wozniakjan wozniakjan merged commit 6387651 into kedacore:main Apr 11, 2026
45 of 48 checks passed
@rickbrouwer rickbrouwer removed the Awaiting/2nd-approval This PR needs one more approval review label Apr 13, 2026
Abhicodeitout pushed a commit to Abhicodeitout/keda that referenced this pull request Apr 13, 2026
…erviceURL (kedacore#7642)

Signed-off-by: Pierre Roudier <[email protected]>
Signed-off-by: Abhishek Kumar Kushwaha <[email protected]>
@proudier proudier deleted the metrics-api-fix branch April 13, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metrics API scaler with aggregateFromKubeServiceEndpoints spuriously probes all pods in namespace

3 participants