Skip to content

Commit af84cbf

Browse files
authored
x-pack/filebeat/i.../entitya.../.../okta: Avoid a negative request rate (#40267) (#40460)
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.
1 parent 8097d6d commit af84cbf

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
9898
- Prevent GCP Pub/Sub input blockage by increasing default value of `max_outstanding_messages` {issue}35029[35029] {pull}38985[38985]
9999
- Updated Websocket input title to align with existing inputs {pull}39006[39006]
100100
- Relax requirements in Okta entity analytics provider user and device profile data shape. {pull}40359[40359]
101+
- Fix bug in Okta entity analytics rate limit logic. {issue}40106[40106] {pull}40267[40267]
101102

102103
*Heartbeat*
103104

x-pack/filebeat/input/entityanalytics/provider/okta/internal/okta/okta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ func oktaRateLimit(h http.Header, window time.Duration, limiter *rate.Limiter) e
380380
rateLimit := rate.Limit(rem / per)
381381

382382
// Process reset if we need to wait until reset to avoid a request against a zero quota.
383-
if rateLimit == 0 {
383+
if rateLimit <= 0 {
384384
waitUntil := resetTime.UTC()
385385
// next gives us a sane next window estimate, but the
386386
// estimate will be overwritten when we make the next

0 commit comments

Comments
 (0)