From b92f46a55f8994c8e7db5ac2cc7a8e243d1a4670 Mon Sep 17 00:00:00 2001 From: mingzhe Date: Wed, 24 Jan 2024 20:20:01 +0100 Subject: [PATCH 1/3] start Signed-off-by: mingzhe --- pkg/queue/queue_rpc.go | 5 ++++- scaler/queue_pinger.go | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/queue/queue_rpc.go b/pkg/queue/queue_rpc.go index 53c6c4642..dbb758be4 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": -1}, + } + return m, nil } defer resp.Body.Close() counts := NewCounts() diff --git a/scaler/queue_pinger.go b/scaler/queue_pinger.go index 65002015d..958e70f49 100644 --- a/scaler/queue_pinger.go +++ b/scaler/queue_pinger.go @@ -254,5 +254,9 @@ func fetchCounts( } } + 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 } From 987be34546b415eae17c61a81b88cc0e37245c2e Mon Sep 17 00:00:00 2001 From: mingzhe Date: Thu, 25 Jan 2024 18:57:31 +0100 Subject: [PATCH 2/3] add comment Signed-off-by: Mizhentaotuo Signed-off-by: mingzhe --- pkg/queue/queue_rpc.go | 2 +- scaler/queue_pinger.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/queue/queue_rpc.go b/pkg/queue/queue_rpc.go index dbb758be4..3bf5915f9 100644 --- a/pkg/queue/queue_rpc.go +++ b/pkg/queue/queue_rpc.go @@ -66,7 +66,7 @@ func GetCounts( resp, err := httpCl.Get(interceptorURL.String()) if err != nil { m := &Counts{ - Counts: map[string]int{"all failed": -1}, + Counts: map[string]int{"all failed": 0}, } return m, nil } diff --git a/scaler/queue_pinger.go b/scaler/queue_pinger.go index 958e70f49..abf67b9ea 100644 --- a/scaler/queue_pinger.go +++ b/scaler/queue_pinger.go @@ -254,6 +254,8 @@ 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") } From 2f08ab4aaf367199626681254f4237bbf8c7a940 Mon Sep 17 00:00:00 2001 From: mingzhe Date: Thu, 25 Jan 2024 19:08:23 +0100 Subject: [PATCH 3/3] add CHANGELOG Signed-off-by: Mizhentaotuo Signed-off-by: mingzhe --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfd5560b2..dba6e1642 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))