fix(backups): hand every driver the same forcePathStyle

backupStorage.forcePathStyle reaches drivers that read it differently.
The controller, Velero and the ClickHouse sidecar parse it with
strconv.ParseBool, the etcd and MongoDB strategies write it into a
boolean field that Helm decodes as YAML 1.1, and the Kafka and
RabbitMQ scripts take anything but the string "false" as path style.
So "False" meant path style to Kafka and RabbitMQ only; "yes" meant
path style to etcd, MongoDB, Kafka and RabbitMQ and was refused by
Velero and the ClickHouse sidecar; "T" and "1" could not be applied to
the boolean fields.

The chart now accepts the spellings of strconv.ParseBool and of YAML
1.1 booleans, a superset of the boolean spellings the etcd and MongoDB
strategies accepted, and passes every consumer "true" or "false", so
they agree. Unset stays unset, so each driver keeps its own default.
Any other value fails the render with a message naming it.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
This commit is contained in:
Alexey Artamonov committed 2026-11-06 17:56:59 +03:00
1 parent 33608326f1
commit 9376ba0078
9 files changed
+541 -6

No files matched your search

@@ -187,3 +187,28 @@ true
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
backupStorage.forcePathStyle as "true", "false", or "" when unset. Its
consumers read it differently: the controller and Velero parse it with
strconv.ParseBool, the etcd and MongoDB strategies write it into a boolean
field that Helm decodes as YAML 1.1 (so "yes" or "off" is a boolean there),
and the Kafka and RabbitMQ scripts compare the string with "false".
Normalising it here means a spelling cannot mean path style to some drivers
and not to others. The spellings accepted are those of strconv.ParseBool and
of YAML 1.1 booleans, a superset of the boolean spellings the etcd and
MongoDB strategies accepted; any other value fails the render.
*/}}
{{- define "backupstrategy-controller.forcePathStyle" -}}
{{- $value := .Values.backupStorage.forcePathStyle -}}
{{- if not (kindIs "invalid" $value) -}}
{{- $raw := toString $value -}}
{{- if has $raw (list "1" "t" "T" "true" "True" "TRUE" "y" "Y" "yes" "Yes" "YES" "on" "On" "ON") -}}
true
{{- else if has $raw (list "0" "f" "F" "false" "False" "FALSE" "n" "N" "no" "No" "NO" "off" "Off" "OFF") -}}
false
{{- else if ne $raw "" -}}
{{- fail (printf "backupStorage.forcePathStyle must be a boolean or unset, got %q" $raw) -}}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -47,7 +47,7 @@ spec:
- name: BACKUP_STORAGE_REGION
value: {{ .Values.backupStorage.region | quote }}
- name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: {{ .Values.backupStorage.forcePathStyle | quote }}
value: {{ include "backupstrategy-controller.forcePathStyle" . | quote }}
- name: BACKUP_STORAGE_SYSTEM_NAMESPACES
value: {{ .Values.backupStorage.systemNamespaces | join "," | quote }}
{{- if .Values.backupStorage.reconcileDefaultObjects }}
@@ -13,7 +13,7 @@ spec:
endpoint: {{ include "backupstrategy-controller.endpoint" . | quote }}
key: {{ printf "{{ .Application.metadata.namespace }}/{{ .Application.metadata.name }}/" | quote }}
region: {{ .Values.backupStorage.region | quote }}
forcePathStyle: {{ .Values.backupStorage.forcePathStyle }}
forcePathStyle: {{ include "backupstrategy-controller.forcePathStyle" . }}
# The etcd-operator reads AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY
# from this Secret by default (no explicit key fields like the
# MariaDB strategy's *SecretKeyRef). The projector writes exactly
@@ -67,7 +67,7 @@ spec:
- name: S3_REGION
value: {{ .Values.backupStorage.region | quote }}
- name: S3_FORCE_PATH_STYLE
value: {{ .Values.backupStorage.forcePathStyle | quote }}
value: {{ include "backupstrategy-controller.forcePathStyle" . | quote }}
command: ["/usr/bin/bash", "-c"]
# The driver script is kept as a standalone shell file and
# embedded verbatim so hack/kafka-backup-script.bats can execute
@@ -74,6 +74,6 @@ spec:
prefix: {{ printf "{{ .Application.metadata.namespace }}/{{ .Application.metadata.name }}" | quote }}
region: {{ .Values.backupStorage.region | quote }}
credentialsSecret: cozy-backups-creds
forcePathStyle: {{ .Values.backupStorage.forcePathStyle }}
forcePathStyle: {{ include "backupstrategy-controller.forcePathStyle" . }}
insecureSkipTLSVerify: {{ .Values.backupStorage.insecureSkipTLSVerify }}
{{- end -}}
@@ -96,7 +96,7 @@ spec:
- name: S3_REGION
value: {{ .Values.backupStorage.region | quote }}
- name: S3_FORCE_PATH_STYLE
value: {{ .Values.backupStorage.forcePathStyle | quote }}
value: {{ include "backupstrategy-controller.forcePathStyle" . | quote }}
command: ["/bin/sh", "-c"]
args:
- |
@@ -29,7 +29,7 @@ spec:
key: cloud
config:
region: {{ .Values.backupStorage.region | quote }}
s3ForcePathStyle: {{ .Values.backupStorage.forcePathStyle | quote }}
s3ForcePathStyle: {{ include "backupstrategy-controller.forcePathStyle" . | quote }}
s3Url: {{ include "backupstrategy-controller.endpoint" . | quote }}
{{- end }}
{{- end }}
@@ -54,3 +54,12 @@ tests:
name: BACKUP_STORAGE_SECRET_NAMESPACE
value: tenant-root
any: true
# A value no consumer took as a boolean is refused once, at render time; see
# tests/force_path_style_test.yaml for what each consumer receives.
- it: "forcePathStyle that is no boolean spelling fails the render and names the value"
set:
backupStorage.forcePathStyle: "maybe"
asserts:
- failedTemplate:
errorPattern: 'backupStorage\.forcePathStyle must be a boolean or unset, got "maybe"'
@@ -0,0 +1,501 @@
suite: forcePathStyle — one normalised boolean for every consumer
# backupStorage.forcePathStyle reaches drivers that read it differently: the
# controller and Velero parse it with strconv.ParseBool, the etcd and MongoDB
# strategies write it into a boolean field Helm decodes as YAML 1.1, and the
# Kafka and RabbitMQ scripts compare the string with "false". The chart accepts
# the spellings of both strconv.ParseBool and YAML 1.1, hands each consumer
# "true" or "false", and refuses anything else, so a spelling cannot mean path
# style to one driver and not to another.
templates:
- templates/deployment.yaml
- templates/strategy-etcd-default.yaml
- templates/strategy-mongodb-default.yaml
- templates/strategy-kafka-default.yaml
- templates/strategy-rabbitmq-default.yaml
- templates/velero-bsl.yaml
release:
name: t
namespace: cozy-backup-controller
set:
backupStorage.bucketNameOverride: test-bucket
tests:
- it: "forcePathStyle '1' reaches the controller as true"
set:
backupStorage.forcePathStyle: "1"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 't' reaches the controller as true"
set:
backupStorage.forcePathStyle: "t"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'T' reaches every consumer as true"
set:
backupStorage.forcePathStyle: "T"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- equal:
path: spec.template.destination.s3.forcePathStyle
value: true
template: templates/strategy-etcd-default.yaml
- equal:
path: spec.template.s3.forcePathStyle
value: true
template: templates/strategy-mongodb-default.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: S3_FORCE_PATH_STYLE
value: "true"
template: templates/strategy-kafka-default.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: S3_FORCE_PATH_STYLE
value: "true"
template: templates/strategy-rabbitmq-default.yaml
- equal:
path: spec.config.s3ForcePathStyle
value: "true"
template: templates/velero-bsl.yaml
- it: "forcePathStyle 'true' reaches the controller as true"
set:
backupStorage.forcePathStyle: "true"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'True' reaches the controller as true"
set:
backupStorage.forcePathStyle: "True"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'TRUE' reaches the controller as true"
set:
backupStorage.forcePathStyle: "TRUE"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'y' reaches the controller as true"
set:
backupStorage.forcePathStyle: "y"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'Y' reaches the controller as true"
set:
backupStorage.forcePathStyle: "Y"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'yes' reaches every consumer as true"
set:
backupStorage.forcePathStyle: "yes"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- equal:
path: spec.template.destination.s3.forcePathStyle
value: true
template: templates/strategy-etcd-default.yaml
- equal:
path: spec.template.s3.forcePathStyle
value: true
template: templates/strategy-mongodb-default.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: S3_FORCE_PATH_STYLE
value: "true"
template: templates/strategy-kafka-default.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: S3_FORCE_PATH_STYLE
value: "true"
template: templates/strategy-rabbitmq-default.yaml
- equal:
path: spec.config.s3ForcePathStyle
value: "true"
template: templates/velero-bsl.yaml
- it: "forcePathStyle 'Yes' reaches the controller as true"
set:
backupStorage.forcePathStyle: "Yes"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'YES' reaches the controller as true"
set:
backupStorage.forcePathStyle: "YES"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'on' reaches the controller as true"
set:
backupStorage.forcePathStyle: "on"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'On' reaches the controller as true"
set:
backupStorage.forcePathStyle: "On"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle 'ON' reaches the controller as true"
set:
backupStorage.forcePathStyle: "ON"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- it: "forcePathStyle '0' reaches the controller as false"
set:
backupStorage.forcePathStyle: "0"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'f' reaches the controller as false"
set:
backupStorage.forcePathStyle: "f"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'F' reaches the controller as false"
set:
backupStorage.forcePathStyle: "F"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'false' reaches the controller as false"
set:
backupStorage.forcePathStyle: "false"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'False' reaches every consumer as false"
set:
backupStorage.forcePathStyle: "False"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- equal:
path: spec.template.destination.s3.forcePathStyle
value: false
template: templates/strategy-etcd-default.yaml
- equal:
path: spec.template.s3.forcePathStyle
value: false
template: templates/strategy-mongodb-default.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: S3_FORCE_PATH_STYLE
value: "false"
template: templates/strategy-kafka-default.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: S3_FORCE_PATH_STYLE
value: "false"
template: templates/strategy-rabbitmq-default.yaml
- equal:
path: spec.config.s3ForcePathStyle
value: "false"
template: templates/velero-bsl.yaml
- it: "forcePathStyle 'FALSE' reaches the controller as false"
set:
backupStorage.forcePathStyle: "FALSE"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'n' reaches the controller as false"
set:
backupStorage.forcePathStyle: "n"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'N' reaches the controller as false"
set:
backupStorage.forcePathStyle: "N"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'no' reaches the controller as false"
set:
backupStorage.forcePathStyle: "no"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'No' reaches the controller as false"
set:
backupStorage.forcePathStyle: "No"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'NO' reaches the controller as false"
set:
backupStorage.forcePathStyle: "NO"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'off' reaches every consumer as false"
set:
backupStorage.forcePathStyle: "off"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- equal:
path: spec.template.destination.s3.forcePathStyle
value: false
template: templates/strategy-etcd-default.yaml
- equal:
path: spec.template.s3.forcePathStyle
value: false
template: templates/strategy-mongodb-default.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: S3_FORCE_PATH_STYLE
value: "false"
template: templates/strategy-kafka-default.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: S3_FORCE_PATH_STYLE
value: "false"
template: templates/strategy-rabbitmq-default.yaml
- equal:
path: spec.config.s3ForcePathStyle
value: "false"
template: templates/velero-bsl.yaml
- it: "forcePathStyle 'Off' reaches the controller as false"
set:
backupStorage.forcePathStyle: "Off"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle 'OFF' reaches the controller as false"
set:
backupStorage.forcePathStyle: "OFF"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "false"
template: templates/deployment.yaml
- it: "forcePathStyle as a YAML boolean (the default) reaches every consumer as true"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: "true"
template: templates/deployment.yaml
- equal:
path: spec.template.destination.s3.forcePathStyle
value: true
template: templates/strategy-etcd-default.yaml
- it: "forcePathStyle as a YAML boolean false reaches the scripts as false"
set:
backupStorage.forcePathStyle: false
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: S3_FORCE_PATH_STYLE
value: "false"
template: templates/strategy-kafka-default.yaml
- equal:
path: spec.template.s3.forcePathStyle
value: false
template: templates/strategy-mongodb-default.yaml
- it: "forcePathStyle as the number 1 reaches the boolean fields as true"
set:
backupStorage.forcePathStyle: 1
asserts:
- equal:
path: spec.template.destination.s3.forcePathStyle
value: true
template: templates/strategy-etcd-default.yaml
# Unset leaves each driver its own default, as before.
- it: "forcePathStyle null stays unset for every consumer"
set:
backupStorage.forcePathStyle: null
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: ""
template: templates/deployment.yaml
- equal:
path: spec.template.destination.s3.forcePathStyle
value: null
template: templates/strategy-etcd-default.yaml
- equal:
path: spec.template.s3.forcePathStyle
value: null
template: templates/strategy-mongodb-default.yaml
- it: "forcePathStyle empty stays unset for every consumer"
set:
backupStorage.forcePathStyle: ""
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BACKUP_STORAGE_FORCE_PATH_STYLE
value: ""
template: templates/deployment.yaml
- equal:
path: spec.template.destination.s3.forcePathStyle
value: null
template: templates/strategy-etcd-default.yaml