Skip to content

fix(fluentbit): render namespaced rewrite_tag filter as YAML when configFileFormat=yaml - #2019

Open
pujitha24 wants to merge 2 commits into
fluent:masterfrom
pujitha24:auto/issue-1689
Open

fix(fluentbit): render namespaced rewrite_tag filter as YAML when configFileFormat=yaml#2019
pujitha24 wants to merge 2 commits into
fluent:masterfrom
pujitha24:auto/issue-1689

Conversation

@pujitha24

Copy link
Copy Markdown
Contributor

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 #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 ./...
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

…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>
Copilot AI review requested due to automatic review settings July 30, 2026 16:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…y goconst lint

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@pujitha24

Copy link
Copy Markdown
Contributor Author

The "Run linter" check was failing on a goconst finding (string \yaml` has 3 occurrences, make it a constant) at controllers/fluentbitconfig_controller.go:290. I've fixed that by extracting the literal into a shared configFileFormatYamlconstant incontrollers/consts.goand using it at both call sites plus the test. Confirmed locally with golangci-lint v2.11.4 (matching CI): 0 issues after the change, and reverting it reproduces the exact reported issue.go build, go vet`, and the affected test packages all still pass. No other feedback is pending on this PR right now.

Copilot AI review requested due to automatic review settings July 30, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: configFileFormat=yaml broken when using namespaced configuration

2 participants