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

chore: Cleanup Fluent Bit config generation #1204

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions internal/reconciler/logpipeline/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,7 @@ func (r *Reconciler) reconcileFluentBit(ctx context.Context, pipeline *telemetry
return fmt.Errorf("failed to reconcile fluent bit metrics service: %w", err)
}

includeSections := true
if len(pipelines) == 0 {
includeSections = false
}
cm := fluentbit.MakeConfigMap(r.config.DaemonSet, includeSections)
cm := fluentbit.MakeConfigMap(r.config.DaemonSet)
if err := k8sutils.CreateOrUpdateConfigMap(ctx, ownerRefSetter, cm); err != nil {
return fmt.Errorf("failed to reconcile fluent bit configmap: %w", err)
}
Expand Down
6 changes: 2 additions & 4 deletions internal/resources/fluentbit/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func MakeExporterMetricsService(name types.NamespacedName) *corev1.Service {
}
}

func MakeConfigMap(name types.NamespacedName, includeSections bool) *corev1.ConfigMap {
func MakeConfigMap(name types.NamespacedName) *corev1.ConfigMap {
parserConfig := `
[PARSER]
Name docker_no_time
Expand All @@ -348,11 +348,9 @@ func MakeConfigMap(name types.NamespacedName, includeSections bool) *corev1.Conf
storage.path /data/flb-storage/
storage.metrics on

@INCLUDE dynamic/*.conf
`
fluentBitConfig = strings.Replace(fluentBitConfig, "{{ HTTP_PORT }}", strconv.Itoa(ports.HTTP), 1)
if includeSections {
fluentBitConfig = fluentBitConfig + "@INCLUDE dynamic/*.conf" + "\n"
}

return &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand Down
2 changes: 1 addition & 1 deletion internal/resources/fluentbit/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestMakeExporterMetricsService(t *testing.T) {

func TestMakeConfigMap(t *testing.T) {
name := types.NamespacedName{Name: "telemetry-fluent-bit", Namespace: "telemetry-system"}
cm := MakeConfigMap(name, true)
cm := MakeConfigMap(name)

require.NotNil(t, cm)
require.Equal(t, cm.Name, name.Name)
Expand Down
3 changes: 1 addition & 2 deletions webhook/dryrun/file_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ func (f *fileWriterImpl) PreparePipelineDryRun(ctx context.Context, workDir stri
func (f *fileWriterImpl) writeConfig(ctx context.Context, basePath string) error {
var cm corev1.ConfigMap
var err error
includeSection := true
err = f.client.Get(ctx, f.config.FluentBitConfigMapName, &cm)
if err != nil {
if apierrors.IsNotFound(err) {
newCm := fluentbit.MakeConfigMap(f.config.FluentBitConfigMapName, includeSection)
newCm := fluentbit.MakeConfigMap(f.config.FluentBitConfigMapName)
cm = *newCm
} else {
return err
Expand Down
Loading