out_opentelemetry: preserve failed log batch results - #12385
Conversation
A later successful OTLP log batch can overwrite an earlier failure and release the whole chunk without retrying the rejected records. Stop batching on the first non-OK flush result after clearing the freed batch. Let the existing cleanup path return that result to the engine. This retains whole-chunk retry and permanent-error handling. Signed-off-by: Yegor Grol <17448507+grolegor@users.noreply.github.com>
Exercise first, middle and last batch failures, partial batches, batch boundaries, both HTTP 429 orders, HTTP 400 and all-success controls. Use HTTP and native OTLP inputs, including 2000 records in two batches. Check per-event delivery and duplicates, whole-chunk retry, permanent failure accounting and the lifecycle of one task. Signed-off-by: Yegor Grol <17448507+grolegor@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe OpenTelemetry log processor now stops decoding after a failed batch flush. A new HTTP integration scenario tests batching, retryable and permanent failures, record handling, metrics, emitted batches, and task lifecycle behavior. ChangesOpenTelemetry log batch retry
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This prevents failed OpenTelemetry log batches from being reported as successful and is ready to merge with the supplied retry, failure, lifecycle, and memory-safety validation. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Hi @cosmo0920, could you please rerun these two CI jobs when you have a chance?
Thank you! |
Fixes #12384.
Problem and fix
One input chunk can produce several OTLP log requests. If an earlier request
returns HTTP 429 and a later request succeeds, the later
FLB_OKoverwritesFLB_RETRY. Fluent Bit releases the chunk without retrying the rejected logs.Stop the batching loop on the first non-OK result, after resetting the freed
batch. The existing cleanup path then returns the failure to the engine.
With two records and
batch_size: 1:This retains whole-chunk retry: if A was accepted before B failed, A can be
duplicated on retry. It does not add exactly-once delivery, change HTTP status
classification, change retry limits, or modify the metrics/traces exporters.
A non-retryable result, such as HTTP 400, is also preserved: the engine drops
the chunk instead of reporting success. Later batches are not sent after that
failure. The tests cover both first- and last-batch HTTP 400 responses.
Tests
The 15 new integration cases use either one JSON array sent to the HTTP input
or one native OTLP request containing separate resource groups. They decode
received OTLP payloads and check per-event delivery, complete batches, retries,
permanent failures, and creation/destruction of one task. The standalone
three-file reproduction remains available in the issue.
Local verification used Linux/arm64 in Docker. The patch was built on current
master (
f78472443d32691c319c424c75d9ea2343dbc8f7) and on tagv5.1.1.All 40 OpenTelemetry integration cases pass on patched master, both normally
and with strict Valgrind 3.18.1. All 40 memory reports show zero errors and no
remaining heap allocations. On the unpatched binary, seven of the 15 new cases
fail as expected and eight controls pass. A separate real integration run with
injected metrics
ConnectionErrorandTimeoutalso passes.Both DCO-signed commits pass the repository's commit-prefix checker over the
full PR range against
master.Commands run inside the development container, from
tests/integration:From the repository root:
ctest --test-dir build -R '^flb-it-opentelemetry$' --output-on-failureCTest result: 1/1 target passed. Representative Valgrind output (the same clean
summary was verified for all 40 tested processes):
Example test configuration
The integration harness provides the ports,
TEST_LOG_BATCH_SIZE, andTEST_LOG_INPUT(httporopentelemetry). Default body keys support both inputs.Fixed 5.1.1 reproduction output
The inverse order delivers both records with one duplicate. Both failure orders
also deliver all 2000 records with
batch_size: 1000; an initial successfulbatch produces 1000 duplicates on whole-chunk retry. Each case has one task.
Submission checklist
Testing
ok-package-testlabel: no packaging or build-system changes.Documentation
Backporting
Developed with AI assistance; verification used real local Fluent Bit processes
and a test receiver, not mocked delivery results.
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
Bug Fixes
Tests