From de8c76dcd56c7ea0b8cbf7dfc72ab03d8c773408 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Thu, 25 Jul 2024 06:22:38 +0930 Subject: [PATCH] x-pack/filebeat/input/cel: avoid a negative request rate (#40270) This is the minimal change necessary to fix the following problem. Around the time of a rate limit reset, if current time is after the reset time returned in response headers, the rate limiting code will set a negative target rate, and if that's done at a time when no request budget has accumulated, it will not recover and will wait forever. --- CHANGELOG.next.asciidoc | 1 + x-pack/filebeat/input/cel/input.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index d5cca89ad77..6f049e46b06 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -160,6 +160,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Fix for Google Workspace duplicate events issue by adding canonical sorting over fingerprint keys array to maintain key order. {pull}40055[40055] {issue}39859[39859] - Fix handling of deeply nested numeric values in HTTP Endpoint CEL programs. {pull}40115[40115] - Prevent panic in CEL and salesforce inputs when github.com/hashicorp/go-retryablehttp exceeds maximum retries. {pull}40144[40144] +- Fix bug in CEL input rate limit logic. {issue}40106[40106] {pull}40270[40270] *Heartbeat* diff --git a/x-pack/filebeat/input/cel/input.go b/x-pack/filebeat/input/cel/input.go index d9e3f977909..99d5cfad788 100644 --- a/x-pack/filebeat/input/cel/input.go +++ b/x-pack/filebeat/input/cel/input.go @@ -659,7 +659,7 @@ func handleRateLimit(log *logp.Logger, rateLimit map[string]interface{}, header } // Process reset if we need to wait until reset to avoid a request against a zero quota. - if limit == 0 { + if limit <= 0 { w, ok := rateLimit["reset"] if ok { switch w := w.(type) {