Skip to content
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

processor: input: output: organize initialization sequence for processor #7396

Conversation

cosmo0920
Copy link
Contributor

In #7071, users reported SEGV when including rewrite_tag plugin within processor stack.
This can be occurred with initialization order for filter plugins on the stack.
All of plugins must be initialized through flb_engine_start to initialize event loop and storage and other required instances correctly.
This PR fixes the invalid initialization of processor stack which includes rewrite_tag plugin.


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:

  • Example configuration file for the change
pipeline:
    inputs:
      - name: dummy
        tag: test-tag.raw
        dummy: '{"tool": "fluent", "sub": {"s1": {"s2": "bit"}}}'

        processors:
          logs:
            - name: modify
              match: test-tag.*
              add: hostname monox
            - name: rewrite_tag
              match: test-tag.*
              rule: $tool ^(fluent)$  from.$TAG.new.$tool.$sub['s1']['s2'].out false
              emitter_name: re_emitted

    outputs:
      - name: stdout
        match: '*'

        processors:
          logs:
            - name: lua
              call: add_field
              code: |
                  function add_field(tag, timestamp, record)
                     new_record = record
                     new_record["output"] = "new data"
                     return 1, timestamp, new_record
                  end
  • Debug log output from testing the change
Fluent Bit v2.1.3
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/05/16 16:38:41] [ info] Configuration:
[2023/05/16 16:38:41] [ info]  flush time     | 1.000000 seconds
[2023/05/16 16:38:41] [ info]  grace          | 5 seconds
[2023/05/16 16:38:41] [ info]  daemon         | 0
[2023/05/16 16:38:41] [ info] ___________
[2023/05/16 16:38:41] [ info]  inputs:
[2023/05/16 16:38:41] [ info]      dummy
[2023/05/16 16:38:41] [ info] ___________
[2023/05/16 16:38:41] [ info]  filters:
[2023/05/16 16:38:41] [ info] ___________
[2023/05/16 16:38:41] [ info]  outputs:
[2023/05/16 16:38:41] [ info]      stdout.0
[2023/05/16 16:38:41] [ info] ___________
[2023/05/16 16:38:41] [ info]  collectors:
[2023/05/16 16:38:41] [ info] [fluent bit] version=2.1.3, commit=815496155e, pid=1717500
[2023/05/16 16:38:41] [debug] [engine] coroutine stack size: 24576 bytes (24.0K)
[2023/05/16 16:38:41] [ info] [storage] ver=1.2.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/05/16 16:38:41] [ info] [cmetrics] version=0.6.1
[2023/05/16 16:38:41] [ info] [ctraces ] version=0.3.0
[2023/05/16 16:38:41] [ info] [input:dummy:dummy.0] initializing
[2023/05/16 16:38:41] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2023/05/16 16:38:41] [debug] [dummy:dummy.0] created event channels: read=21 write=22
[2023/05/16 16:38:41] [debug] [filter:modify:modify.0] Initialized modify filter with 0 conditions and 1 rules
[2023/05/16 16:38:41] [ info] [input:emitter:re_emitted] initializing
[2023/05/16 16:38:41] [ info] [input:emitter:re_emitted] storage_strategy='memory' (memory only)
[2023/05/16 16:38:41] [debug] [emitter:re_emitted] created event channels: read=23 write=24
[2023/05/16 16:38:41] [debug] [stdout:stdout.0] created event channels: read=25 write=26
[2023/05/16 16:38:41] [ info] [output:stdout:stdout.0] worker #0 started
[2023/05/16 16:38:41] [debug] [router] match rule dummy.0:stdout.0
[2023/05/16 16:38:41] [debug] [router] match rule emitter.1:stdout.0
[2023/05/16 16:38:41] [ info] [sp] stream processor started
[2023/05/16 16:38:41] [debug] [input chunk] update output instances with new chunk size diff=65
[2023/05/16 16:38:42] [debug] [task] created task=0x7f69b0047660 id=0 OK
[2023/05/16 16:38:42] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[0] from.test-tag.raw.new.fluent.bit.out: [[1684222721.442910671, {}], {"sub"=>{"s1"=>{"s2"=>"bit"}}, "tool"=>"fluent", "output"=>"new data", "hostname"=>"monox"}]
[2023/05/16 16:38:42] [debug] [input chunk] update output instances with new chunk size diff=65
[2023/05/16 16:38:42] [debug] [out flush] cb_destroy coro_id=0
[2023/05/16 16:38:42] [debug] [task] destroy task=0x7f69b0047660 (task_id=0)
[2023/05/16 16:38:43] [debug] [task] created task=0x7f69b0046be0 id=0 OK
[2023/05/16 16:38:43] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[0] from.test-tag.raw.new.fluent.bit.out: [[1684222722.442936182, {}], {"sub"=>{"s1"=>{"s2"=>"bit"}}, "tool"=>"fluent", "output"=>"new data", "hostname"=>"monox"}]
[2023/05/16 16:38:43] [debug] [input chunk] update output instances with new chunk size diff=65
[2023/05/16 16:38:43] [debug] [out flush] cb_destroy coro_id=1
[2023/05/16 16:38:43] [debug] [task] destroy task=0x7f69b0046be0 (task_id=0)
^C[2023/05/16 16:38:44] [engine] caught signal (SIGINT)
[2023/05/16 16:38:44] [debug] [task] created task=0x7f69b0046e00 id=0 OK
[2023/05/16 16:38:44] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2023/05/16 16:38:44] [ warn] [engine] service will shutdown in max 5 seconds
[2023/05/16 16:38:44] [ info] [input] pausing dummy.0
[0] from.test-tag.raw.new.fluent.bit.out: [[1684222723.442939758, {}], {"sub"=>{"s1"=>{"s2"=>"bit"}}, "tool"=>"fluent", "output"=>"new data", "hostname"=>"monox"}]
[2023/05/16 16:38:44] [debug] [out flush] cb_destroy coro_id=2
[2023/05/16 16:38:44] [debug] [task] destroy task=0x7f69b0046e00 (task_id=0)
[2023/05/16 16:38:44] [ info] [engine] service has stopped (0 pending tasks)
[2023/05/16 16:38:44] [ info] [input] pausing dummy.0
[2023/05/16 16:38:44] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/05/16 16:38:44] [ info] [output:stdout:stdout.0] thread worker #0 stopped
  • Attached Valgrind output that shows no leaks or memory corruption was found
==1717689== 
==1717689== HEAP SUMMARY:
==1717689==     in use at exit: 0 bytes in 0 blocks
==1717689==   total heap usage: 2,992 allocs, 2,992 frees, 3,248,250 bytes allocated
==1717689== 
==1717689== All heap blocks were freed -- no leaks are possible
==1717689== 
==1717689== For lists of detected and suppressed errors, rerun with: -s
==1717689== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

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.

@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 07:40 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 07:40 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 07:40 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 changed the title processor: input: output: organize initailization sequence for processor processor: input: output: organize initialization sequence for processor May 16, 2023
src/flb_input.c Outdated Show resolved Hide resolved
src/flb_processor.c Outdated Show resolved Hide resolved
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:03 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:06 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:06 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:06 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:32 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:49 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:49 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:49 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 force-pushed the cosmo0920-organize-initailization-sequence-for-processor branch from d3ff1fc to 35db259 Compare May 16, 2023 08:58
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:59 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:59 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 08:59 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 force-pushed the cosmo0920-organize-initailization-sequence-for-processor branch from 1284cb3 to c8c4905 Compare May 16, 2023 09:05
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 09:08 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 09:08 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 09:08 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 marked this pull request as ready for review May 16, 2023 09:12
@cosmo0920 cosmo0920 requested a review from edsiper as a code owner May 16, 2023 09:12
@cosmo0920 cosmo0920 temporarily deployed to pr May 16, 2023 09:29 — with GitHub Actions Inactive
@leonardo-albertovich leonardo-albertovich merged commit dc68553 into master May 17, 2023
@leonardo-albertovich leonardo-albertovich deleted the cosmo0920-organize-initailization-sequence-for-processor branch May 17, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants