Skip to content

Handle NaN result from Prometheus#7522

Merged
rickbrouwer merged 6 commits into
kedacore:mainfrom
tcp13equals2:issue-7475-fix-prometheus-metric-value-nan
Mar 31, 2026
Merged

Handle NaN result from Prometheus#7522
rickbrouwer merged 6 commits into
kedacore:mainfrom
tcp13equals2:issue-7475-fix-prometheus-metric-value-nan

Conversation

@tcp13equals2

@tcp13equals2 tcp13equals2 commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

This PR seeks to address #7475.

When a Prometheus query is used for obtaining a scaler value the existing code will handle an Inf value being returned. However, if Prometheus returns a NaN this is not explicitly handled.

As a consequence, the NaN is parsed into a float64 and passed back for use in further evaluations.

This PR simply adds an additional test to ensure that NaN and Inf responses are handled in the same manner. This can result in arithmetic overflows and bogus keda_scaler_metrics_value being calculated.

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 #7475

@tcp13equals2 tcp13equals2 requested a review from a team as a code owner March 6, 2026 00:50
@github-actions

github-actions Bot commented Mar 6, 2026

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.

@keda-automation keda-automation requested a review from a team March 6, 2026 00:50
@snyk-io

snyk-io Bot commented Mar 6, 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.

Signed-off-by: Andrew Hall <[email protected]>
Signed-off-by: Andrew Hall <[email protected]>
@rickbrouwer

rickbrouwer commented Mar 6, 2026

Copy link
Copy Markdown
Member

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

Comment thread CHANGELOG.md Outdated
Co-authored-by: Rick Brouwer <[email protected]>
Signed-off-by: Andrew Hall <[email protected]>
@tcp13equals2 tcp13equals2 requested a review from rickbrouwer March 6, 2026 08:01
@keda-automation keda-automation requested review from a team and removed request for rickbrouwer March 6, 2026 08:01
@rickbrouwer

rickbrouwer commented Mar 6, 2026

Copy link
Copy Markdown
Member

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

@rickbrouwer rickbrouwer enabled auto-merge (squash) March 6, 2026 08:28
@rickbrouwer rickbrouwer added the Awaiting/2nd-approval This PR needs one more approval review label Mar 6, 2026
@keda-automation keda-automation requested a review from a team March 25, 2026 02:20
@rickbrouwer

rickbrouwer commented Mar 25, 2026

Copy link
Copy Markdown
Member

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

@rickbrouwer rickbrouwer merged commit 711d9fc into kedacore:main Mar 31, 2026
25 checks passed
akarki2005 pushed a commit to akarki2005/keda that referenced this pull request Apr 6, 2026
* Handle NaN result from Prometheus in the same way as handling Inf
* Update CHANGELOG.md

Co-authored-by: Rick Brouwer <[email protected]>
Signed-off-by: Andrew Hall <[email protected]>
jansworld pushed a commit to jansworld/keda that referenced this pull request Apr 10, 2026
* Handle NaN result from Prometheus in the same way as handling Inf
* Update CHANGELOG.md

Co-authored-by: Rick Brouwer <[email protected]>
Signed-off-by: Andrew Hall <[email protected]>
Signed-off-by: jansworld <[email protected]>
@rickbrouwer rickbrouwer removed the Awaiting/2nd-approval This PR needs one more approval review label Apr 13, 2026
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.

Prometheus metric value does not handle NaN result

3 participants