Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update zero result return to be non-error inducing #695

Merged
merged 1 commit into from
Mar 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/scalers/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (s *prometheusScaler) IsActive(ctx context.Context) (bool, error) {
prometheusLog.Error(err, "error executing prometheus query")
return false, err
}

return val > 0, nil
return val > -1, nil
}

func (s *prometheusScaler) Close() error {
Expand Down Expand Up @@ -144,9 +144,9 @@ func (s *prometheusScaler) ExecutePromQuery() (float64, error) {

var v float64 = -1

// only allow for single element result sets
// allow for zero element or single element result sets
if len(result.Data.Result) == 0 {
return -1, fmt.Errorf("Prometheus query %s returned empty", s.metadata.query)
return 0, nil
} else if len(result.Data.Result) > 1 {
return -1, fmt.Errorf("Prometheus query %s returned multiple elements", s.metadata.query)
}
Expand Down