Repository navigation
out_opensearch_data_stream: honor pipeline - #205
Conversation
opensearch_data_stream accepts the pipeline parameter from the regular output but never sends it, so records skip the configured ingest pipeline without any warning. Add it to the bulk request, with the chunk placeholders filled in as the regular output does. Signed-off-by: Lucas Barros <[email protected]>
Watson1978
left a comment
There was a problem hiding this comment.
Thanks for the fix. I checked it with OpenSearch 3.9.0. A pipeline given on the _bulk request is applied to the data stream, and the ${tag} placeholder works too.
Two changes are needed before merging. Details are in the inline comments.
- Do not send the pipeline parameter when the expanded value is empty. OpenSearch rejects
?pipeline=for the whole request. - Expand the pipeline at the top of
write, before the records are processed.
OpenSearch rejects the whole bulk request for ?pipeline=, so do not send the parameter when the pipeline is empty or its placeholders expand to an empty string. Expand the pipeline at the top of write, so a chunk whose pipeline cannot be built fails before any record is sent to @error. Co-authored-by: Shizuo Fujita <[email protected]> Signed-off-by: Lucas Barros <[email protected]>
Watson1978
left a comment
There was a problem hiding this comment.
Thanks for the update. Both requested changes are implemented in 81d86dc. Empty pipeline values are no longer sent, and the three new tests fail on 1cef9dd and pass now.
However, my second request introduced a regression, and I am sorry about that. When the pipeline cannot be built, a chunk with only invalid records no longer reaches @ERROR. Details, a possible fix, and tests are in the inline comment.
…pipeline Expanding the pipeline at the top of write kept a chunk with only invalid records from reaching @error. Collect the invalid records, expand the pipeline only when there are valid ones, and then send the invalid records to @error. When the pipeline cannot be built, a mixed chunk is still backed up as a whole. Signed-off-by: Lucas Barros <[email protected]>
|
No problem, thanks for the follow-up. Pushed 6aeed9c:
|
|
The Ruby 3.1 jobs on macOS and Windows fail in the new test The other jobs pass. The test expects Could you make this test pass with Fluentd versions before 1.19.3 too? For example, skip it there, or make the expansion fail in a way that does not depend on that check. The change in |
… Fluentd 1.19.3 Signed-off-by: Lucas Barros <[email protected]>
|
Thanks for checking CI. Pushed 3b1fbac:
|
Watson1978
left a comment
There was a problem hiding this comment.
Thanks for the update. I verified the version check in 3b1fbac locally. I ran the data stream tests with Fluentd 1.18.0, 1.19.2, 1.19.3, and 1.19.4. The mixed-chunk test is omitted before 1.19.3, and it runs and passes from 1.19.3 on.
However, the change I asked for in my second review causes another regression, and I am sorry about that. It also affects configurations without pipeline. Details and a fix are in the inline comment.
The existing tests can stay as they are. A test for the shutdown timing is not needed.
…p without a pipeline When the output shuts down during a long write, Fluentd sets router to nil, so emitting the invalid records after the loop raised NoMethodError and the whole chunk was handled as unrecoverable, also without pipeline. Keep them for later only when pipeline is set, and with emit_error_label_event false do not keep them at all. Signed-off-by: Lucas Barros <[email protected]>
Watson1978
left a comment
There was a problem hiding this comment.
Thanks for applying the change. I checked b07980a locally.
- Without
pipeline, the shutdown reproduction from my last review now behaves likemain. - With
pipelineset and error events enabled, a record with an invalid ID reached@ERRORwhen it was alone in the chunk. When I added a valid record and the pipeline could not be built, the rejected record did not reach@ERROR. - The full test suite passes, also when merged with
mainat 76c177e. The data stream tests pass with Fluentd 1.18.0 (one omission) and 1.19.4.
LGTM.
opensearch_data_streaminherits thepipelineparameter fromopensearch, but itswritebuilds the bulk request with onlyindexandbody, so the parameter is ignored and records skip the ingest pipeline with no warning. OpenSearch applies an ingest pipeline given on a_bulkrequest to data streams too, so nothing on the server side stops this from working.The output expands a configured
pipelinesuch aspipeline-${tag}after checking the records, and only if at least one record is ready for the bulk request. A non-empty result is sent as thepipelinequery parameter. With error events enabled, records rejected during those checks go to@ERRORright away whenpipelineis unset. Withpipelineset, they go after a successful expansion, or without expansion when all records were rejected. Ifpipelineis not set, or it is empty after expansion (OpenSearch rejects?pipeline=for the whole request), the request is unchanged. A shortpipelineentry was added to the Data Stream section of the README, like theid_keyone added in #200.Tests added to
test/plugin/test_out_opensearch_data_stream.rb:test_record_with_pipeline, with a fixed value and a${tag}placeholder. The bulk request must carry?pipeline=mypipelineor?pipeline=pipeline-test. Both fail onmainbecause the request goes out without the query parameter.test_record_with_empty_pipelineandtest_record_with_pipeline_placeholder_expanded_to_empty: nopipelinequery parameter is sent.test_invalid_records_go_to_error_when_pipeline_cannot_be_builtandtest_chunk_with_valid_records_is_not_sent_to_error_when_pipeline_cannot_be_built: with a tag that cannot be used in a placeholder, a chunk with only an invalid record sends it to@ERROR, a chunk with an invalid and a valid record sends nothing to@ERROR, and no bulk request is made in either case.bundle exec rake test: 466 tests, 0 failures, 0 errors.Not marked backward compatible: the data stream output now sends the configured
pipelinewhen its expanded value is non-empty.(check all that apply)
versionin gemspec are untouched