Skip to content

Commit

Permalink
update zero result return to be non-error inducing
Browse files Browse the repository at this point in the history
  • Loading branch information
droessmj authored Mar 20, 2020
1 parent 3692eca commit ac53c20
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit ac53c20

Please sign in to comment.