-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
config: yaml: add support for cfl_arrays when a property is declared as a list. #8661
Conversation
Here is a valgrind log: 2024/04/01 18:14:14] [ info] [fluent bit] version=3.0.1, commit=cf3e53ce03, pid=275574
[2024/04/01 18:14:14] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/04/01 18:14:14] [ info] [output:stdout:stdout.0] worker #0 started
[2024/04/01 18:14:14] [ info] [cmetrics] version=0.7.1
[2024/04/01 18:14:14] [ info] [ctraces ] version=0.4.0
[2024/04/01 18:14:14] [ info] [input:dummy:dummy.0] initializing
[2024/04/01 18:14:14] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2024/04/01 18:14:14] [ info] [sp] stream processor started
[0] dummy.0: [[1712006055.007001399, {}], {"message"=>"foobar", "foobar"=>"barfoo"}]
[0] dummy.0: [[1712006056.003066368, {}], {"message"=>"foobar", "foobar"=>"barfoo"}]
^C[2024/04/01 18:14:17] [engine] caught signal (SIGINT)
[2024/04/01 18:14:17] [ warn] [engine] service will shutdown in max 5 seconds
[0] dummy.0: [[1712006056.991977440, {}], {"message"=>"foobar", "foobar"=>"barfoo"}]
[2024/04/01 18:14:17] [ info] [input] pausing dummy.0
[2024/04/01 18:14:17] [ info] [engine] service has stopped (0 pending tasks)
[2024/04/01 18:14:17] [ info] [input] pausing dummy.0
[2024/04/01 18:14:17] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2024/04/01 18:14:17] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==275574==
==275574== HEAP SUMMARY:
==275574== in use at exit: 0 bytes in 0 blocks
==275574== total heap usage: 1,992 allocs, 1,992 frees, 1,450,877 bytes allocated
==275574==
==275574== All heap blocks were freed -- no leaks are possible
==275574==
==275574== For lists of detected and suppressed errors, rerun with: -s
==275574== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) |
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.
Basically, it looks good to me.
Is there any chance to add an internal unit test case for this PR?
Or, this will be covered by another derived works?
I'm also interested in defining to the multiple server destinations on out_forward plugin like Fluentd does.
…essors. Add support for arrays of variant values for both plugins and processors. The Support for these values still needs to be added to the config and config_map levels. Signed-off-by: Phillip Whelan <[email protected]>
Only set properties for plugins within arrays when the type is of type variant string. This avoids memory access problems when properties are set as lists. Signed-off-by: Phillip Whelan <[email protected]>
a minor typo was incorrectly constructing the properties for processors. Signed-off-by: Phillip Whelan <[email protected]>
Signed-off-by: Phillip Whelan <[email protected]>
dfe55d7
to
3320d63
Compare
I will be adding tests as soon as the work for I could also push those changes to this branch if it is better to try and get the entire feature merged at once but I felt the |
This was initially based on fluent#8656 and fluent#8661 but ended up making few different choices: - Instead of adding FLB_CONFIG_MAP_KVLIST and FLB_CONFIG_MAP_ARRAY as config map types, it adds a single FLB_CONFIG_MAP_VARIANT which accepts an array or map. The passed array/map can have nested values and accept any JSON/YAML types, which are converted to cfl types. The processor will simply receive a `cfl_variant` pointer and is responsible for releasing the memory later. - The existing `flb_config_map_set` function is reused by passing the `cfl_variant` pointer (from the yaml parsing phase) as the value of a `flb_kv`. Then pointer is eventually moved into the processor context. Signed-off-by: Thiago Padilha <[email protected]>
This was initially based on fluent#8656 and fluent#8661 but ended up making few different choices: - Instead of adding FLB_CONFIG_MAP_KVLIST and FLB_CONFIG_MAP_ARRAY as config map types, it adds a single FLB_CONFIG_MAP_VARIANT which accepts an array or map. The passed array/map can have nested values and accept any JSON/YAML types, which are converted to cfl types. The processor will simply receive a `cfl_variant` pointer but doesn't own it, the config section is responsible for releasing its memory. - The existing `flb_config_map_set` function is reused by passing the `cfl_variant` pointer (from the yaml parsing phase) as the value of a `flb_kv`. Then pointer is eventually passed to the processor context. Signed-off-by: Thiago Padilha <[email protected]>
This was initially based on fluent#8656 and fluent#8661 but ended up making few different choices: - Instead of adding FLB_CONFIG_MAP_KVLIST and FLB_CONFIG_MAP_ARRAY as config map types, it adds a single FLB_CONFIG_MAP_VARIANT which accepts an array or map. The passed array/map can have nested values and accept any JSON/YAML types, which are converted to cfl types. The processor will simply receive a `cfl_variant` pointer but doesn't own it, the config section is responsible for releasing its memory. - The existing `flb_config_map_set` function is reused by passing the `cfl_variant` pointer (from the yaml parsing phase) as the value of a `flb_kv`. Then pointer is eventually passed to the processor context. Signed-off-by: Thiago Padilha <[email protected]>
This was initially based on fluent#8656 and fluent#8661 but ended up making few different choices: - Instead of adding FLB_CONFIG_MAP_KVLIST and FLB_CONFIG_MAP_ARRAY as config map types, it adds a single FLB_CONFIG_MAP_VARIANT which accepts an array or map. The passed array/map can have nested values and accept any JSON/YAML types, which are converted to cfl types. The processor will simply receive a `cfl_variant` pointer but doesn't own it, the config section is responsible for releasing its memory. - The existing `flb_config_map_set` function is reused by passing the `cfl_variant` pointer (from the yaml parsing phase) as the value of a `flb_kv`. Then pointer is eventually passed to the processor context. Signed-off-by: Thiago Padilha <[email protected]>
This was initially based on fluent#8656 and fluent#8661 but ended up making few different choices: - Instead of adding FLB_CONFIG_MAP_KVLIST and FLB_CONFIG_MAP_ARRAY as config map types, it adds a single FLB_CONFIG_MAP_VARIANT which accepts an array or map. The passed array/map can have nested values and accept any JSON/YAML types, which are converted to cfl types. The processor will simply receive a `cfl_variant` pointer but doesn't own it, the config section is responsible for releasing its memory. - The existing `flb_config_map_set` function is reused by passing the `cfl_variant` pointer (from the yaml parsing phase) as the value of a `flb_kv`. Then pointer is eventually passed to the processor context. Signed-off-by: Thiago Padilha <[email protected]>
This was initially based on #8656 and #8661 but ended up making few different choices: - Instead of adding FLB_CONFIG_MAP_KVLIST and FLB_CONFIG_MAP_ARRAY as config map types, it adds a single FLB_CONFIG_MAP_VARIANT which accepts an array or map. The passed array/map can have nested values and accept any JSON/YAML types, which are converted to cfl types. The processor will simply receive a `cfl_variant` pointer but doesn't own it, the config section is responsible for releasing its memory. - The existing `flb_config_map_set` function is reused by passing the `cfl_variant` pointer (from the yaml parsing phase) as the value of a `flb_kv`. Then pointer is eventually passed to the processor context. Signed-off-by: Thiago Padilha <[email protected]>
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Superseded elsewhere. |
Summary
When a property is declared as a list with variant values it will be parsed using cfl_array with variants inside.
An example is this:
This should also work with arrays that have key/vales, ie:
This also works with processors and will be key for an upcoming feature for the
content_modifier
processor:This pull request does not attempt to actually allow passing these properties to a plugin. Changes to the config and config_map layer are required for these values to actually be passed to a plugin instance.
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:
Documentation
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.