Skip to content

Commit

Permalink
fix: consider empty results set from new relic (#5621)
Browse files Browse the repository at this point in the history
* consider empty results set from new relic

Signed-off-by: cyrilico <[email protected]>

* update changelog

Signed-off-by: cyrilico <[email protected]>

* fix changelog order

Signed-off-by: cyrilico <[email protected]>

---------

Signed-off-by: cyrilico <[email protected]>
Signed-off-by: damas <[email protected]>
  • Loading branch information
cyrilico authored Mar 26, 2024
1 parent 2354412 commit 6bc6139
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Here is an overview of all new **experimental** features:
- **General**: Prometheus metrics shows errors correctly ([#5597](https://github.com/kedacore/keda/issues/5597))
- **General**: Validate empty array value of triggers in ScaledObject/ScaledJob creation ([#5520](https://github.com/kedacore/keda/issues/5520))
- **GitHub Runner Scaler**: Fixed `in_progress` detection on running jobs instead of just `queued` ([#5604](https://github.com/kedacore/keda/issues/5604))
- **New Relic Scaler**: Consider empty results set from query executer ([#5619](https://github.com/kedacore/keda/pull/5619))

### Deprecations

Expand Down
7 changes: 7 additions & 0 deletions pkg/scalers/newrelic_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ func (s *newrelicScaler) executeNewRelicQuery(ctx context.Context) (float64, err
if err != nil {
return 0, fmt.Errorf("error running NRQL %s (%s)", s.metadata.nrql, err.Error())
}
// Check for empty results set, as New Relic lib does not report these as errors
if len(resp.Results) == 0 {
if s.metadata.noDataError {
return 0, fmt.Errorf("query return no results %s", s.metadata.nrql)
}
return 0, nil
}
// Only use the first result from the query, as the query should not be multi row
for _, v := range resp.Results[0] {
val, ok := v.(float64)
Expand Down

0 comments on commit 6bc6139

Please sign in to comment.