diff --git a/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go b/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go index 7cb30d32e..dc4183438 100644 --- a/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go +++ b/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go @@ -280,8 +280,8 @@ func (cfg ClusterFluentBitConfig) RenderMainConfig(sl plugins.SecretLoader, inpu func (cfg ClusterFluentBitConfig) RenderParserConfig(sl plugins.SecretLoader, parsers ClusterParserList, nsParserLists []ParserList, nsClusterParserLists []ClusterParserList) (string, error) { var buf bytes.Buffer - - parserSections, err := parsers.Load(sl) + existingParsers := make(map[string]bool) + parserSections, err := parsers.Load(sl, existingParsers) if err != nil { return "", err } @@ -304,7 +304,7 @@ func (cfg ClusterFluentBitConfig) RenderParserConfig(sl plugins.SecretLoader, pa } for _, item := range nsClusterParserLists { - nsClusterParserSections, err := item.Load(sl) + nsClusterParserSections, err := item.Load(sl, existingParsers) if err != nil { return "", err } diff --git a/apis/fluentbit/v1alpha2/clusterparser_types.go b/apis/fluentbit/v1alpha2/clusterparser_types.go index ef4e9c590..3b4d22731 100644 --- a/apis/fluentbit/v1alpha2/clusterparser_types.go +++ b/apis/fluentbit/v1alpha2/clusterparser_types.go @@ -88,12 +88,14 @@ func (a ParserByName) Len() int { return len(a) } func (a ParserByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a ParserByName) Less(i, j int) bool { return a[i].Name < a[j].Name } -func (list ClusterParserList) Load(sl plugins.SecretLoader) (string, error) { +func (list ClusterParserList) Load(sl plugins.SecretLoader, existingParsers map[string]bool) (string, error) { var buf bytes.Buffer sort.Sort(ParserByName(list.Items)) - for _, item := range list.Items { + if existingParsers[item.Name] { + continue + } merge := func(p plugins.Plugin) error { if p == nil || reflect.ValueOf(p).IsNil() { return nil @@ -117,6 +119,7 @@ func (list ClusterParserList) Load(sl plugins.SecretLoader) (string, error) { buf.WriteString(fmt.Sprintf(" Decode_Field_As %s\n", decorder.DecodeFieldAs)) } } + existingParsers[item.Name] = true return nil }