fix(fluentbit): render namespaced rewrite_tag filter as YAML when configFileFormat=yaml - #2019
Open
pujitha24 wants to merge 2 commits into
Open
fix(fluentbit): render namespaced rewrite_tag filter as YAML when configFileFormat=yaml#2019pujitha24 wants to merge 2 commits into
pujitha24 wants to merge 2 commits into
Conversation
…figFileFormat=yaml Motivation: When a FluentBitConfig's ClusterFluentBitConfig sets spec.configFileFormat: yaml, and a namespaced Filter/FluentBitConfig triggers the operator's auto-generated `rewrite_tag` filter (used to tag records emitted from a given namespace), the operator always rendered that filter as a hand-written classic TOML snippet (`[Filter]\n Name rewrite_tag\n...`) and spliced it directly into the otherwise-YAML fluent-bit.yaml secret. The result is a config file that mixes TOML and YAML syntax, which fluent-bit fails to parse at startup. This only affects the yaml config format combined with the namespaced rewrite-tag scenario; the classic/TOML format and non-namespaced setups are unaffected, and the operator's reconcile loop itself completes without error since it has no visibility into the malformed content it writes. Fixes fluent#1689 Approach: Instead of hand-building a format-specific string, generateRewriteTagConfig now constructs the existing filter.RewriteTag plugin struct (same Rule/EmitterName/ EmitterStorageType/EmitterMemBufLimit values as before) wrapped in a synthetic ClusterFilterList, and renders it through the same Load()/LoadAsYaml() methods already used for user-defined Filter and ClusterFilter resources. A new configFileFormat parameter is threaded from ClusterFluentBitConfig.Spec.ConfigFileFormat through processNamespacedFluentBitCfgs into generateRewriteTagConfig to pick the right renderer. The classic TOML output is unchanged apart from a harmless reordering of the Emitter_* keys (order doesn't matter in fluent-bit's classic format). Validation: - go build ./... - go test ./controllers/... ./apis/fluentbit/v1alpha2/... (all packages pass, including a new TestGenerateRewriteTagConfigYaml covering both the yaml and classic output paths) - go vet ./... ```release-note Fixed a bug where namespaced Filter resources combined with `configFileFormat: yaml` produced an invalid fluent-bit.yaml config (TOML text mixed into YAML) for the auto-generated rewrite_tag filter, causing fluent-bit to fail to parse its configuration. ``` Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
…y goconst lint Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Contributor
Author
|
The "Run linter" check was failing on a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
When a FluentBitConfig's ClusterFluentBitConfig sets
spec.configFileFormat: yaml, and a namespaced Filter/FluentBitConfig
triggers the operator's auto-generated
rewrite_tagfilter (used totag records emitted from a given namespace), the operator always
rendered that filter as a hand-written classic TOML snippet
(
[Filter]\n Name rewrite_tag\n...) and spliced it directly intothe otherwise-YAML fluent-bit.yaml secret. The result is a config file
that mixes TOML and YAML syntax, which fluent-bit fails to parse at
startup. This only affects the yaml config format combined with the
namespaced rewrite-tag scenario; the classic/TOML format and
non-namespaced setups are unaffected, and the operator's reconcile
loop itself completes without error since it has no visibility into
the malformed content it writes.
Fixes #1689
Approach:
Instead of hand-building a format-specific string,
generateRewriteTagConfig now constructs the existing
filter.RewriteTag plugin struct (same Rule/EmitterName/
EmitterStorageType/EmitterMemBufLimit values as before) wrapped in a
synthetic ClusterFilterList, and renders it through the same
Load()/LoadAsYaml() methods already used for user-defined Filter and
ClusterFilter resources. A new configFileFormat parameter is threaded
from ClusterFluentBitConfig.Spec.ConfigFileFormat through
processNamespacedFluentBitCfgs into generateRewriteTagConfig to pick
the right renderer. The classic TOML output is unchanged apart from a
harmless reordering of the Emitter_* keys (order doesn't matter in
fluent-bit's classic format).
Validation:
(all packages pass, including a new TestGenerateRewriteTagConfigYaml
covering both the yaml and classic output paths)
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com