From 915bc35a77fdeab39f5b8668c57fd3c8207db751 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. (cherry picked from commit de8c76dcd56c7ea0b8cbf7dfc72ab03d8c773408) --- 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 87fed62c14e9..aef906cb86e0 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -154,6 +154,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - 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] - Update CEL mito extensions to v1.13.1. {pull}40307[40307] +- 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 d9e3f9779091..99d5cfad7889 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) {