From 8257ea9dc950cd49064ec9786543e5cb314e18c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=27Perk=27=20Sto=C5=BCek?= Date: Thu, 18 Feb 2021 18:14:15 +0100 Subject: [PATCH] fix: v2 migration script - info on new default value for fluent-bit.image.pullPolicy key instead of just adding it --- deploy/helm/sumologic/upgrade-2.0.0.sh | 10 +++-- .../static/fluent_bit.input.yaml | 1 + tests/upgrade_v2_script/static/fluent_bit.log | 2 + .../static/fluent_bit.output.yaml | 1 + .../static/fluent_bit_image.input.yaml | 6 +++ .../static/fluent_bit_image.log | 11 +++++ .../static/fluent_bit_image.output.yaml | 5 +++ .../static/fluent_bit_no_image.input.yaml | 39 ++++++++++++++++++ .../static/fluent_bit_no_image.log | 5 +++ .../static/fluent_bit_no_image.output.yaml | 40 +++++++++++++++++++ 10 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 tests/upgrade_v2_script/static/fluent_bit_image.input.yaml create mode 100644 tests/upgrade_v2_script/static/fluent_bit_image.log create mode 100644 tests/upgrade_v2_script/static/fluent_bit_image.output.yaml create mode 100644 tests/upgrade_v2_script/static/fluent_bit_no_image.input.yaml create mode 100644 tests/upgrade_v2_script/static/fluent_bit_no_image.log create mode 100644 tests/upgrade_v2_script/static/fluent_bit_no_image.output.yaml diff --git a/deploy/helm/sumologic/upgrade-2.0.0.sh b/deploy/helm/sumologic/upgrade-2.0.0.sh index 4b79ecabf0..749ce8e2f6 100755 --- a/deploy/helm/sumologic/upgrade-2.0.0.sh +++ b/deploy/helm/sumologic/upgrade-2.0.0.sh @@ -650,8 +650,12 @@ function migrate_fluent_bit() { yq w -i "${TEMP_FILE}" 'fluent-bit.env.(name==CHART).name' FLUENTD_LOGS_SVC fi - if [[ -n "$(yq r "${TEMP_FILE}" -- 'fluent-bit.image.fluent_bit')" ]]; then - yq w -i "${TEMP_FILE}" 'fluent-bit.image.pullPolicy' IfNotPresent + local default_image_pull_policy="IfNotPresent" + local image_pull_policy + readonly image_pull_policy="$(yq r "${TEMP_FILE}" -- 'fluent-bit.image.pullPolicy')" + if [[ -n ${image_pull_policy} ]] && [[ ${image_pull_policy} != "${default_image_pull_policy}" ]]; then + info "Leaving the fluent-bit.image.pullPolicy set to '${image_pull_policy}'" + info "Please note that in v2.0 the fluent-bit.image.pullPolicy is set to '${default_image_pull_policy}' by default" fi local default_image_tag="1.6.10" @@ -660,7 +664,7 @@ function migrate_fluent_bit() { if [[ -n ${image_tag} ]] && [[ ${image_tag} != "${default_image_tag}" ]]; then info "Leaving the fluent-bit.image.tag set to '${image_tag}'" info "Please note that in v2.0 the fluent-bit.image.tag is set to '${default_image_tag}' by default" - fi + fi if [[ -n "$(yq r "${TEMP_FILE}" -- 'fluent-bit.service.flush')" ]]; then yq w -i "${TEMP_FILE}" 'fluent-bit.service.labels."sumologic.com/scrape"' --style double true diff --git a/tests/upgrade_v2_script/static/fluent_bit.input.yaml b/tests/upgrade_v2_script/static/fluent_bit.input.yaml index cff15b0c9f..fdb4b9807e 100644 --- a/tests/upgrade_v2_script/static/fluent_bit.input.yaml +++ b/tests/upgrade_v2_script/static/fluent_bit.input.yaml @@ -39,6 +39,7 @@ fluent-bit: fluent_bit: repository: public.ecr.aws/sumologic/fluent-bit tag: 1.6.0 + pullPolicy: Always service: flush: 5 metrics: diff --git a/tests/upgrade_v2_script/static/fluent_bit.log b/tests/upgrade_v2_script/static/fluent_bit.log index 625c16f205..debef6b502 100644 --- a/tests/upgrade_v2_script/static/fluent_bit.log +++ b/tests/upgrade_v2_script/static/fluent_bit.log @@ -2,6 +2,8 @@ [INFO] Mapping fluent-bit.image.fluent_bit.tag into fluent-bit.image.tag [INFO] Migrating prometheus remote write urls +[INFO] Leaving the fluent-bit.image.pullPolicy set to 'Always' +[INFO] Please note that in v2.0 the fluent-bit.image.pullPolicy is set to 'IfNotPresent' by default [INFO] Leaving the fluent-bit.image.tag set to '1.6.0' [INFO] Please note that in v2.0 the fluent-bit.image.tag is set to '1.6.10' by default [INFO] Migrating "fluent-bit.backend.forward.host" from "${CHART}.${NAMESPACE}.svc.cluster.local." to "${FLUENTD_LOGS_SVC}.${NAMESPACE}.svc.cluster.local." diff --git a/tests/upgrade_v2_script/static/fluent_bit.output.yaml b/tests/upgrade_v2_script/static/fluent_bit.output.yaml index 6227b6f8a2..5ecb8a525a 100644 --- a/tests/upgrade_v2_script/static/fluent_bit.output.yaml +++ b/tests/upgrade_v2_script/static/fluent_bit.output.yaml @@ -38,6 +38,7 @@ fluent-bit: image: repository: public.ecr.aws/sumologic/fluent-bit tag: 1.6.0 + pullPolicy: Always service: labels: sumologic.com/scrape: "true" diff --git a/tests/upgrade_v2_script/static/fluent_bit_image.input.yaml b/tests/upgrade_v2_script/static/fluent_bit_image.input.yaml new file mode 100644 index 0000000000..e9c2ed2fae --- /dev/null +++ b/tests/upgrade_v2_script/static/fluent_bit_image.input.yaml @@ -0,0 +1,6 @@ +fluent-bit: + image: + fluent_bit: + repository: public.ecr.aws/sumologic/fluent-bit + tag: 1.6.0 + pullPolicy: Always diff --git a/tests/upgrade_v2_script/static/fluent_bit_image.log b/tests/upgrade_v2_script/static/fluent_bit_image.log new file mode 100644 index 0000000000..5df027d59b --- /dev/null +++ b/tests/upgrade_v2_script/static/fluent_bit_image.log @@ -0,0 +1,11 @@ +[INFO] Mapping fluent-bit.image.fluent_bit.repository into fluent-bit.image.repository +[INFO] Mapping fluent-bit.image.fluent_bit.tag into fluent-bit.image.tag + +[INFO] Migrating prometheus remote write urls +[INFO] Leaving the fluent-bit.image.pullPolicy set to 'Always' +[INFO] Please note that in v2.0 the fluent-bit.image.pullPolicy is set to 'IfNotPresent' by default +[INFO] Leaving the fluent-bit.image.tag set to '1.6.0' +[INFO] Please note that in v2.0 the fluent-bit.image.tag is set to '1.6.10' by default + +Thank you for upgrading to v2.0.0 of the Sumo Logic Kubernetes Collection Helm chart. +A new yaml file has been generated for you. Please check the current directory for new_values.yaml. diff --git a/tests/upgrade_v2_script/static/fluent_bit_image.output.yaml b/tests/upgrade_v2_script/static/fluent_bit_image.output.yaml new file mode 100644 index 0000000000..cfbd4d99d2 --- /dev/null +++ b/tests/upgrade_v2_script/static/fluent_bit_image.output.yaml @@ -0,0 +1,5 @@ +fluent-bit: + image: + repository: public.ecr.aws/sumologic/fluent-bit + tag: 1.6.0 + pullPolicy: Always diff --git a/tests/upgrade_v2_script/static/fluent_bit_no_image.input.yaml b/tests/upgrade_v2_script/static/fluent_bit_no_image.input.yaml new file mode 100644 index 0000000000..d181e858ca --- /dev/null +++ b/tests/upgrade_v2_script/static/fluent_bit_no_image.input.yaml @@ -0,0 +1,39 @@ +fluent-bit: + podLabels: {} + podAnnotations: {} + env: + - name: CHART + valueFrom: + configMapKeyRef: + name: sumologic-configmap + key: fluentdLogs + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + extraVolumes: + - name: project2-db + emptyDir: {} + - name: project-db + emptyDir: {} + - name: project2-alerts + hostPath: + path: /var/project2/logs/alerts/alerts.json + type: File + - name: company-db + emptyDir: {} + extraVolumeMounts: + - name: project2-db + mountPath: /fluent-bit/project2 + - name: project-db + mountPath: /fluent-bit/project + - name: project2-alerts + mountPath: /var/project2/logs/alerts/alerts.json + readOnly: true + - name: company-db + mountPath: /fluent-bit/company + tolerations: + - effect: NoSchedule + operator: Exists + service: + flush: 5 diff --git a/tests/upgrade_v2_script/static/fluent_bit_no_image.log b/tests/upgrade_v2_script/static/fluent_bit_no_image.log new file mode 100644 index 0000000000..0c27db5863 --- /dev/null +++ b/tests/upgrade_v2_script/static/fluent_bit_no_image.log @@ -0,0 +1,5 @@ + +[INFO] Migrating prometheus remote write urls + +Thank you for upgrading to v2.0.0 of the Sumo Logic Kubernetes Collection Helm chart. +A new yaml file has been generated for you. Please check the current directory for new_values.yaml. diff --git a/tests/upgrade_v2_script/static/fluent_bit_no_image.output.yaml b/tests/upgrade_v2_script/static/fluent_bit_no_image.output.yaml new file mode 100644 index 0000000000..48566a4a2f --- /dev/null +++ b/tests/upgrade_v2_script/static/fluent_bit_no_image.output.yaml @@ -0,0 +1,40 @@ +fluent-bit: + podLabels: {} + podAnnotations: {} + env: + - name: FLUENTD_LOGS_SVC + valueFrom: + configMapKeyRef: + name: sumologic-configmap + key: fluentdLogs + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + extraVolumes: + - name: project2-db + emptyDir: {} + - name: project-db + emptyDir: {} + - name: project2-alerts + hostPath: + path: /var/project2/logs/alerts/alerts.json + type: File + - name: company-db + emptyDir: {} + extraVolumeMounts: + - name: project2-db + mountPath: /fluent-bit/project2 + - name: project-db + mountPath: /fluent-bit/project + - name: project2-alerts + mountPath: /var/project2/logs/alerts/alerts.json + readOnly: true + - name: company-db + mountPath: /fluent-bit/company + tolerations: + - effect: NoSchedule + operator: Exists + service: + labels: + sumologic.com/scrape: "true"