From a860ff663537b48378972763d4b6d7e68f8935ed Mon Sep 17 00:00:00 2001 From: Katarzyna Kujawa Date: Thu, 12 Jan 2023 14:02:16 +0100 Subject: [PATCH] fix(update-collection-v3): fix migration of configuration with missing sumologic key and additional configuration under fluentd.logs key --- .../migrations/fluentd-logs-configs/fluentd.go | 10 ++++++++-- ...luent-config-additional-logs-config.input.yaml | 13 +++++++++++++ ...uent-config-additional-logs-config.output.yaml | 15 +++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/testdata/fluent-config-additional-logs-config.input.yaml create mode 100644 src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/testdata/fluent-config-additional-logs-config.output.yaml diff --git a/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/fluentd.go b/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/fluentd.go index 8e5b1f22..95bc4e28 100644 --- a/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/fluentd.go +++ b/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/fluentd.go @@ -7,7 +7,11 @@ func createSumologic(valuesInput *ValuesInput) *SumologicOutput { sumoLogicOutput := &SumologicOutput{} if valuesInput.Fluentd != nil { - sumoLogicOutput.Logs = createSumologicLogs(valuesInput.Fluentd.Logs, valuesInput.Sumologic.Logs) + var valuesInputSumologicLogs *SumologicLogsInput + if valuesInput.Sumologic != nil { + valuesInputSumologicLogs = valuesInput.Sumologic.Logs + } + sumoLogicOutput.Logs = createSumologicLogs(valuesInput.Fluentd.Logs, valuesInputSumologicLogs) } if valuesInput.Sumologic != nil { @@ -136,7 +140,8 @@ func isFluentdOutputEmpty(fluentdInput *Fluentd) bool { isContainersLogRestEmpty(fluentdInput.Logs.Containers) && isLogRestEmpty(fluentdInput.Logs.Systemd) && isLogRestEmpty(fluentdInput.Logs.Kubelet) && - isLogRestEmpty(fluentdInput.Logs.Default)) { + isLogRestEmpty(fluentdInput.Logs.Default)) && + fluentdInput.Logs.Rest == nil { return true } return false @@ -176,6 +181,7 @@ func createFluentdLogs(valuesInput *ValuesInput) *Fluentd { Systemd: createFluentdLogsConfig(valuesInput.Fluentd.Logs.Systemd), Kubelet: createFluentdLogsConfig(valuesInput.Fluentd.Logs.Kubelet), Default: createFluentdLogsConfig(valuesInput.Fluentd.Logs.Default), + Rest: valuesInput.Fluentd.Logs.Rest, }, } } diff --git a/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/testdata/fluent-config-additional-logs-config.input.yaml b/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/testdata/fluent-config-additional-logs-config.input.yaml new file mode 100644 index 00000000..58be8b78 --- /dev/null +++ b/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/testdata/fluent-config-additional-logs-config.input.yaml @@ -0,0 +1,13 @@ +fluentd: + logs: + autoscaling: + enabled: true + maxReplicas: 10 + minReplicas: 3 + targetCPUUtilizationPercentage: 50 + containers: + sourceCategoryReplaceDash: _ + kubelet: + sourceCategoryReplaceDash: _ + systemd: + sourceCategoryReplaceDash: _ diff --git a/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/testdata/fluent-config-additional-logs-config.output.yaml b/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/testdata/fluent-config-additional-logs-config.output.yaml new file mode 100644 index 00000000..b9fd5b56 --- /dev/null +++ b/src/go/cmd/update-collection-v3/migrations/fluentd-logs-configs/testdata/fluent-config-additional-logs-config.output.yaml @@ -0,0 +1,15 @@ +sumologic: + logs: + container: + sourceCategoryReplaceDash: _ + systemd: + sourceCategoryReplaceDash: _ + kubelet: + sourceCategoryReplaceDash: _ +fluentd: + logs: + autoscaling: + enabled: true + maxReplicas: 10 + minReplicas: 3 + targetCPUUtilizationPercentage: 50