From 583cf5509577b164f6528a603c10bc5081bdc9b8 Mon Sep 17 00:00:00 2001 From: Michael Droessler Date: Fri, 20 Mar 2020 06:54:34 -0500 Subject: [PATCH] update zero result return to be non-error inducing Signed-off-by: Michael Droessler --- pkg/scalers/prometheus.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/scalers/prometheus.go b/pkg/scalers/prometheus.go index 21ab221220b..1eaa0133a79 100644 --- a/pkg/scalers/prometheus.go +++ b/pkg/scalers/prometheus.go @@ -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 { @@ -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) }