From 844932e50ca9f857503f01682036899214f3166e Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sat, 28 Dec 2024 05:49:15 +0200 Subject: [PATCH] fix(common): RESTIC_REPOSITORY does not use a valid protocol and needs 2 protocols at some cases (#30336) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # https://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html#s3-compatible-storage image **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning - [ ] I made sure the title starts with `feat(chart-name):`, `fix(chart-name):` or `chore(chart-name):` **➕ 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._ --- .../tests/volsync/replication_dest_spec_test.yaml | 4 ++-- .../tests/volsync/replication_src_spec_test.yaml | 2 +- charts/library/common/Chart.yaml | 2 +- charts/library/common/templates/spawner/_pvc.tpl | 6 +++++- 4 files changed, 9 insertions(+), 5 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 85b1fe49500..3a653db94af 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 @@ -25,7 +25,7 @@ tests: credentials: &credentials mys3: type: s3 - url: http://some-url + url: https://s3.some-url bucket: some-bucket encrKey: some-key accessKey: some-access-key @@ -48,7 +48,7 @@ tests: AWS_ACCESS_KEY_ID: some-access-key AWS_SECRET_ACCESS_KEY: some-secret-key RESTIC_PASSWORD: some-key - RESTIC_REPOSITORY: s3:some-url/some-bucket/test-release-name/volsync/destbackup-volsync-mybackup1 + RESTIC_REPOSITORY: s3:s3.some-url/some-bucket/test-release-name/volsync/destbackup-volsync-mybackup1 - documentIndex: &replicationDestDoc 1 isKind: of: ReplicationDestination 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 60185a7fc19..6290bbfb503 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 @@ -44,7 +44,7 @@ tests: AWS_ACCESS_KEY_ID: some-access-key AWS_SECRET_ACCESS_KEY: some-secret-key RESTIC_PASSWORD: some-key - RESTIC_REPOSITORY: s3:some-url/some-bucket/test-release-name/volsync/srcbackup-volsync-mybackup1 + RESTIC_REPOSITORY: s3:http://some-url/some-bucket/test-release-name/volsync/srcbackup-volsync-mybackup1 - documentIndex: &replicationDestDoc 1 isKind: of: ReplicationSource diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 8f4f19c5d4b..7e05db6695e 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -48,4 +48,4 @@ sources: - https://hub.docker.com/_/ - https://hub.docker.com/r/mikefarah/yq type: library -version: 25.2.3 +version: 25.2.4 diff --git a/charts/library/common/templates/spawner/_pvc.tpl b/charts/library/common/templates/spawner/_pvc.tpl index fc8af8c367d..b4b3b060b4d 100644 --- a/charts/library/common/templates/spawner/_pvc.tpl +++ b/charts/library/common/templates/spawner/_pvc.tpl @@ -102,7 +102,11 @@ {{- $credentials := get $.Values.credentials $volsync.credentials -}} - {{- $url := $credentials.url | replace "http://" "" | replace "https://" "" -}} + {{/* Only amazon needs the https:// trimmed, anything else requires it */}} + {{- $url := $credentials.url -}} + {{- if hasPrefix "https://s3." $url -}} + {{- $url = trimPrefix "https://" $url -}} + {{- end -}} {{- $baseRepo := printf "s3:%s/%s" $url $credentials.bucket -}} {{- $repoSuffix := printf "%s/volsync/%s-volsync-%s" $.Release.Name $objectData.shortName $volsyncData.name -}}