From 5ff012e0c170eaad5a76a9652a5d6b84f0ec628b Mon Sep 17 00:00:00 2001 From: astro-stan <36302090+astro-stan@users.noreply.github.com> Date: Tue, 18 Nov 2025 17:33:47 +0000 Subject: [PATCH] fix(common): Fix generating invalid CA secret names when credentials dict includes uppercase letters (#41548) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [x] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code - [ ] 📜 Documentation Changes **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [X] ⚖️ My code follows the style guidelines of this project - [X] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made changes to the documentation - [X] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [X] ⬆️ I increased versions for any altered app according to semantic versioning - [X] I made sure the title starts with `feat(chart-name):`, `fix(chart-name):`, `chore(chart-name):`, `docs(chart-name):` or `fix(docs):` **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Signed-off-by: Alfred Göppel <43101280+alfi0812@users.noreply.github.com> Signed-off-by: astro-stan <36302090+astro-stan@users.noreply.github.com> Co-authored-by: Alfred Göppel <43101280+alfi0812@users.noreply.github.com> --- .../volsync/replication_dest_spec_test.yaml | 75 ++++++++++++++++ .../volsync/replication_src_spec_test.yaml | 86 +++++++++++++++++++ charts/library/common/Chart.yaml | 1 - .../library/common/templates/spawner/_pvc.tpl | 2 +- 4 files changed, 162 insertions(+), 2 deletions(-) diff --git a/charts/library/common-test/tests/volsync/replication_dest_spec_test.yaml b/charts/library/common-test/tests/volsync/replication_dest_spec_test.yaml index 0fe0db9d17d..43e35caaccb 100644 --- a/charts/library/common-test/tests/volsync/replication_dest_spec_test.yaml +++ b/charts/library/common-test/tests/volsync/replication_dest_spec_test.yaml @@ -496,6 +496,81 @@ tests: runAsUser: 568 runAsGroup: 568 + - it: should generate correct spec with customCA and uppercase credentials name + set: + persistence: + destbackup: + enabled: true + type: pvc + mountPath: /backedup + volsync: + - name: mybackup1 + type: restic + credentials: MyS3 + dest: + enabled: true + src: + enabled: false + credentials: + MyS3: + type: s3 + url: https://s3.some-url + bucket: some-bucket + encrKey: some-key + accessKey: some-access-key + secretKey: some-secret-key + customCA: |- + -----BEGIN CERTIFICATE----- + ... + -----END CERTIFICATE----- + asserts: + - documentIndex: &secretCaDoc 1 + isKind: + of: Secret + - documentIndex: *secretCaDoc + isAPIVersion: + of: v1 + - documentIndex: *secretCaDoc + equal: + path: metadata.name + value: test-release-name-common-test-volsync-ca-mys3 + - documentIndex: *secretCaDoc + equal: + path: stringData + value: + ca.crt: |- + -----BEGIN CERTIFICATE----- + ... + -----END CERTIFICATE----- + - documentIndex: &replicationCaDestDoc 2 + isKind: + of: ReplicationDestination + - documentIndex: *replicationCaDestDoc + isAPIVersion: + of: volsync.backube/v1alpha1 + - documentIndex: *replicationCaDestDoc + equal: + path: spec + value: + trigger: + manual: restore-once + restic: + repository: test-release-name-common-test-destbackup-volsync-mybackup1 + customCA: + secretName: test-release-name-common-test-volsync-ca-mys3 + key: ca.crt + copyMethod: Snapshot + cleanupTempPVC: false + cleanupCachePVC: false + cacheCapacity: 10Gi + capacity: 100Gi + accessModes: + - ReadWriteOnce + moverSecurityContext: + fsGroup: 568 + runAsUser: 568 + runAsGroup: 568 + - it: should generate correct spec with customCASecretRef set: secret: diff --git a/charts/library/common-test/tests/volsync/replication_src_spec_test.yaml b/charts/library/common-test/tests/volsync/replication_src_spec_test.yaml index 5fd15ba4b65..5752f3de8d0 100644 --- a/charts/library/common-test/tests/volsync/replication_src_spec_test.yaml +++ b/charts/library/common-test/tests/volsync/replication_src_spec_test.yaml @@ -507,6 +507,92 @@ tests: path: spec.restic.unlock pattern: "^[0-9]{14}$" + - it: should generate correct spec with customCA and an uppercase credentials name + set: + persistence: + srcbackup: + enabled: true + type: pvc + mountPath: /backedup + volsync: + - name: mybackup1 + type: restic + credentials: MyS3 + dest: + enabled: false + src: + enabled: true + credentials: + MyS3: + type: s3 + url: http://some-url + bucket: some-bucket + encrKey: some-key + accessKey: some-access-key + secretKey: some-secret-key + customCA: |- + -----BEGIN CERTIFICATE----- + ... + -----END CERTIFICATE----- + asserts: + - documentIndex: &secretCaDoc 1 + isKind: + of: Secret + - documentIndex: *secretCaDoc + isAPIVersion: + of: v1 + - documentIndex: *secretCaDoc + equal: + path: metadata.name + value: test-release-name-common-test-volsync-ca-mys3 + - documentIndex: *secretCaDoc + equal: + path: stringData + value: + ca.crt: |- + -----BEGIN CERTIFICATE----- + ... + -----END CERTIFICATE----- + - documentIndex: &replicationCaDestDoc 2 + isKind: + of: ReplicationSource + - documentIndex: *replicationCaDestDoc + isAPIVersion: + of: volsync.backube/v1alpha1 + - documentIndex: *replicationCaDestDoc + isSubset: + path: spec + content: + sourcePVC: test-release-name-common-test-srcbackup + trigger: + schedule: "0 0 * * *" + - documentIndex: *replicationCaDestDoc + isSubset: + path: spec.restic + content: + repository: test-release-name-common-test-srcbackup-volsync-mybackup1 + customCA: + secretName: test-release-name-common-test-volsync-ca-mys3 + key: ca.crt + copyMethod: Snapshot + pruneIntervalDays: 7 + retain: + hourly: 6 + daily: 5 + weekly: 4 + monthly: 3 + yearly: 1 + accessModes: + - ReadWriteOnce + moverSecurityContext: + fsGroup: 568 + runAsUser: 568 + runAsGroup: 568 + - documentIndex: *replicationCaDestDoc + matchRegex: + path: spec.restic.unlock + pattern: "^[0-9]{14}$" + - it: should generate correct spec with customCASecretRef set: secret: diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 999acf47ead..f9d3b95ad55 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -52,4 +52,3 @@ sources: - https://hub.docker.com/r/mikefarah/yq type: library version: 28.26.4 - diff --git a/charts/library/common/templates/spawner/_pvc.tpl b/charts/library/common/templates/spawner/_pvc.tpl index 97dafa14039..7478526f82f 100644 --- a/charts/library/common/templates/spawner/_pvc.tpl +++ b/charts/library/common/templates/spawner/_pvc.tpl @@ -153,7 +153,7 @@ {{- else if $credentials.customCA -}} {{/* Create Custom CA Secret for VolSync */}} - {{- $volsyncCASecretName := printf "%s-volsync-ca-%s" (include "tc.v1.common.lib.chart.names.fullname" $ ) $volsync.credentials -}} + {{- $volsyncCASecretName := printf "%s-volsync-ca-%s" (include "tc.v1.common.lib.chart.names.fullname" $ ) (lower $volsync.credentials) -}} {{- $volsyncCAKey := "ca.crt" -}} {{- $_ := set $volsyncData "customCA" $volsyncCASecretName -}}