-
Notifications
You must be signed in to change notification settings - Fork 1.9k
out_es: fix error treatment on response parsing #11375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
out_es: fix error treatment on response parsing #11375
Conversation
📝 WalkthroughWalkthroughRename status macros and tighten error/cleanup control flow; HTTP response handling broadened to treat 200–299 and 409 as non-error, 400–499 (except 409) as errors, and Changes
Sequence Diagram(s)sequenceDiagram
participant Plugin as Fluent Bit Plugin
participant ES as Elasticsearch (HTTP)
participant Retry as Retry/Emitter
Plugin->>ES: send bulk request
ES-->>Plugin: HTTP response (status, body)
alt status 200-299
Plugin->>Plugin: set FLB_ES_STATUS_SUCCESS
Plugin-->>Retry: acknowledge success (no retry)
else status == 409
Plugin->>Plugin: treat as conflict (non-error)
Plugin-->>Retry: acknowledge (no retry)
else status >= 400 and status < 500
Plugin->>Plugin: set error flags (not pure SUCCESS)
Plugin-->>Retry: schedule retry for failed items
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@plugins/out_es/es.c`:
- Around line 958-961: The comment above the equality check for
FLB_ES_STATUS_SUCCESS incorrectly mentions "OpenSearch" instead of
"Elasticsearch"; update the comment near the equality check (the block that logs
when ret == FLB_ES_STATUS_SUCCESS and calls flb_plg_debug(ctx->ins,
"Elasticsearch response\n%s", c->resp.payload)) to reference "Elasticsearch" so
it correctly reflects this plugin and the behavior of FLB_ES_STATUS_SUCCESS.
8c847fb to
7350c49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@plugins/out_es/es.c`:
- Around line 792-799: The current status-check logic (variable check) only sets
FLB_ES_STATUS_SUCCESS for 2xx and treats non-409 4xx/5xx as FLB_ES_STATUS_ERROR,
which causes batches with only 409 responses to neither be marked success nor
error and thus be retried forever; modify the checks in the status aggregation
(where FLB_ES_STATUS_SUCCESS and FLB_ES_STATUS_ERROR are OR'ed into check) to
also mark 409 responses as success (i.e., treat item_val.via.i64 == 409 the same
as the 2xx case) so all-409 batches return FLB_ES_STATUS_SUCCESS and do not
retry indefinitely.
7350c49 to
c7f2250
Compare
Previously, any response containing 'errors=true' was considered successful if there were at least one message with 200/201 status, regarding any error statuses. In addition, all status codes other than 409 (including range [200;299]) caused the FLB_ES_STATUS_ERROR bit to be set in the 'check' flag. This behavior caused some batches to skip retrying when batch contained errors but had one successful message status. Now the logic of error treatment considers only statuses from range [200;299] as successful and only statuses from range [400;409)&(409;599] as faulty. Afterward, the message batch is considered successful if there were only 2xx statuses or 409 (version conflict), and scheduled for retry if there were any errors ([400;409)&(409;599], or failed response parsing). Signed-off-by: Castor Sky <[email protected]>
c7f2250 to
285c300
Compare
Used cleanup procedure for 'out_buf' and 'result' for the case when errors of JSON parsing occurred. Signed-off-by: Castor Sky <[email protected]>
Adaptation of error parsing fix from OpenSearch module #11374 for Elasticsearch module.
Previously, any response containing 'errors=true' was considered successful if there were at least one message with 200/201 status, regarding any error statuses. In addition, all status codes other than 409 (including range [200;299]) caused the FLB_ES_STATUS_ERROR bit to be set in the 'check' flag. This behavior caused some batches to skip retrying when batch contained errors but had one successful message status.
Now the logic of error treatment considers only statuses from range [200;299] as successful and only statuses from range [400;409)&(409;599] as faulty. Afterward, the message batch is considered successful if there were only 2xx statuses or 409 (version conflict), and scheduled for retry if there were any errors ([400;409)&(409;599], or failed response parsing).
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.