diff --git a/CHANGELOG.md b/CHANGELOG.md index cfd5560b..dba6e164 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This changelog keeps track of work items that have been completed and are ready - [v0.5.0](#v050) ## Unreleased +Scaler fails only when failing to get counts from all the interceptor endpoints. ### Breaking Changes - **General**: TODO ([#TODO](https://github.com/kedacore/http-add-on/issues/TODO)) diff --git a/pkg/queue/queue_rpc.go b/pkg/queue/queue_rpc.go index 53c6c464..3bf5915f 100644 --- a/pkg/queue/queue_rpc.go +++ b/pkg/queue/queue_rpc.go @@ -65,7 +65,10 @@ func GetCounts( interceptorURL.Path = countsPath resp, err := httpCl.Get(interceptorURL.String()) if err != nil { - return nil, fmt.Errorf("requesting the queue counts from %s: %w", interceptorURL.String(), err) + m := &Counts{ + Counts: map[string]int{"all failed": 0}, + } + return m, nil } defer resp.Body.Close() counts := NewCounts() diff --git a/scaler/queue_pinger.go b/scaler/queue_pinger.go index 65002015..abf67b9e 100644 --- a/scaler/queue_pinger.go +++ b/scaler/queue_pinger.go @@ -254,5 +254,11 @@ func fetchCounts( } } + // if fetch all failed, throw error + // if any fetch succeeded, return counts from them + if _, found := totalCounts["all failed"]; found && len(totalCounts) == 1 { + return nil, 0, fmt.Errorf("fetching all counts failed, cannot reach any of the endpoints") + } + return totalCounts, agg, nil }