From 12f212140b71f41e301ce33eb700640bfc2f6233 Mon Sep 17 00:00:00 2001 From: Alexandre Acebedo Date: Thu, 6 Feb 2025 11:50:31 +0100 Subject: [PATCH] feat(common): Add destinationPVC when volsync direct copy method is used (#31659) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** When using direct copy method of volsync, the destinationPVC shall be set in order to restore the file in the corresponding volume. This modification adds the correct attribute when this copy method is active ⚒️ Fixes # **⚙️ Type of change** - [X] ⚙️ 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?** I was not able to test it as I did not found the instruction to load my branch in FluxCD. **📃 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 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._ --------- Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- .github/workflows/common-tests.yaml | 2 + .../ci/volsync-dest-direct-values.yaml | 62 +++++++++++++++++++ .../common-test/ci/volsync-dest-values.yaml | 2 +- .../ci/volsync-src-direct-values.yaml | 62 +++++++++++++++++++ .../common-test/ci/volsync-src-values.yaml | 2 +- .../volsync/replication_dest_spec_test.yaml | 46 ++++++++++++++ .../class/volsync/_replicationDestination.tpl | 6 +- 7 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 charts/library/common-test/ci/volsync-dest-direct-values.yaml create mode 100644 charts/library/common-test/ci/volsync-src-direct-values.yaml diff --git a/.github/workflows/common-tests.yaml b/.github/workflows/common-tests.yaml index 94f344cacdd..ea0e7cb2f28 100644 --- a/.github/workflows/common-tests.yaml +++ b/.github/workflows/common-tests.yaml @@ -159,6 +159,8 @@ jobs: ## TODO: reenable when we've some credentials ready to rock for testing # - volsync-dest-values.yaml # - volsync-src-values.yaml + # - volsync-dest-direct-values.yaml + # - volsync-src-direct-values.yaml steps: - name: Checkout diff --git a/charts/library/common-test/ci/volsync-dest-direct-values.yaml b/charts/library/common-test/ci/volsync-dest-direct-values.yaml new file mode 100644 index 00000000000..fc1592317ac --- /dev/null +++ b/charts/library/common-test/ci/volsync-dest-direct-values.yaml @@ -0,0 +1,62 @@ +service: + main: + enabled: true + primary: true + ports: + main: + enabled: true + primary: true + port: 8080 + +workload: + main: + enabled: true + primary: true + type: Deployment + podSpec: + containers: + main: + enabled: true + primary: true + args: + - --port + - "8080" + probes: + liveness: + enabled: true + type: http + port: "{{ .Values.service.main.ports.main.port }}" + readiness: + enabled: true + type: http + port: "{{ .Values.service.main.ports.main.port }}" + startup: + enabled: true + type: http + port: "{{ .Values.service.main.ports.main.port }}" + +persistence: + destbackup: + enabled: true + type: pvc + mountPath: /backedup + copyMethod: Direct + targetSelectAll: true + volsync: + - name: mybackup + type: restic + copyMethod: Direct + credentials: mys3 + dest: + enabled: true + src: + enabled: false + +credentials: + mys3: + type: s3 + url: "http://test" + bucket: "test" + accessKey: "test" + secretKey: "test" + encrKey: "test" diff --git a/charts/library/common-test/ci/volsync-dest-values.yaml b/charts/library/common-test/ci/volsync-dest-values.yaml index 498cf38aa7b..6ce07c63515 100644 --- a/charts/library/common-test/ci/volsync-dest-values.yaml +++ b/charts/library/common-test/ci/volsync-dest-values.yaml @@ -53,7 +53,7 @@ persistence: credentials: mys3: type: s3 - url: "test" + url: "http://test" bucket: "test" accessKey: "test" secretKey: "test" diff --git a/charts/library/common-test/ci/volsync-src-direct-values.yaml b/charts/library/common-test/ci/volsync-src-direct-values.yaml new file mode 100644 index 00000000000..b74cf240be6 --- /dev/null +++ b/charts/library/common-test/ci/volsync-src-direct-values.yaml @@ -0,0 +1,62 @@ +service: + main: + enabled: true + primary: true + ports: + main: + enabled: true + primary: true + port: 8080 + +workload: + main: + enabled: true + primary: true + type: Deployment + podSpec: + containers: + main: + enabled: true + primary: true + args: + - --port + - "8080" + probes: + liveness: + enabled: true + type: http + port: "{{ .Values.service.main.ports.main.port }}" + readiness: + enabled: true + type: http + port: "{{ .Values.service.main.ports.main.port }}" + startup: + enabled: true + type: http + port: "{{ .Values.service.main.ports.main.port }}" + +persistence: + srcbackup: + enabled: true + type: pvc + mountPath: /backedup + copyMethod: Direct + targetSelectAll: true + volsync: + - name: mybackup + type: restic + credentials: mys3 + copyMethod: Direct + dest: + enabled: false + src: + enabled: true + +credentials: + mys3: + type: s3 + url: "http://test" + bucket: "test" + accessKey: "test" + secretKey: "test" + encrKey: "test" diff --git a/charts/library/common-test/ci/volsync-src-values.yaml b/charts/library/common-test/ci/volsync-src-values.yaml index b5293c33ea3..260bd552ae9 100644 --- a/charts/library/common-test/ci/volsync-src-values.yaml +++ b/charts/library/common-test/ci/volsync-src-values.yaml @@ -53,7 +53,7 @@ persistence: credentials: mys3: type: s3 - url: "test" + url: "http://test" bucket: "test" accessKey: "test" secretKey: "test" 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 28592db08fd..680f0223e00 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 @@ -304,3 +304,49 @@ tests: fsGroup: 568 runAsUser: 568 runAsGroup: 568 + + - it: should generate correct spec with destinationPVC + set: + persistence: + destbackup: + enabled: true + type: pvc + mountPath: /backedup + volsync: + - name: mybackup1 + type: restic + credentials: mys3 + copyMethod: Direct + dest: + enabled: true + capacity: 200Gi + src: + enabled: false + credentials: *credentials + asserts: + - documentIndex: *replicationDestDoc + isKind: + of: ReplicationDestination + - documentIndex: *replicationDestDoc + isAPIVersion: + of: volsync.backube/v1alpha1 + - documentIndex: *replicationDestDoc + equal: + path: spec + value: + trigger: + manual: restore-once + restic: + repository: test-release-name-common-test-destbackup-volsync-mybackup1 + copyMethod: Direct + cleanupTempPVC: false + cleanupCachePVC: false + destinationPVC: test-release-name-common-test-destbackup + cacheCapacity: 10Gi + capacity: 200Gi + accessModes: + - ReadWriteOnce + moverSecurityContext: + fsGroup: 568 + runAsUser: 568 + runAsGroup: 568 diff --git a/charts/library/common/templates/class/volsync/_replicationDestination.tpl b/charts/library/common/templates/class/volsync/_replicationDestination.tpl index ed0cc38ff81..7ca2322c411 100644 --- a/charts/library/common/templates/class/volsync/_replicationDestination.tpl +++ b/charts/library/common/templates/class/volsync/_replicationDestination.tpl @@ -26,6 +26,7 @@ objectData: {{- $cleanupCachePVC = $volsyncData.cleanupCachePVC -}} {{- end -}} + {{- $copyMethod := $volsyncData.copyMethod | default "Snapshot" -}} {{- $capacity := $rootCtx.Values.global.fallbackDefaults.pvcSize -}} {{- if $objectData.size -}} {{- $capacity = $objectData.size -}} @@ -54,8 +55,11 @@ spec: manual: restore-once {{ $volsyncData.type }}: repository: {{ $volsyncData.repository }} - copyMethod: {{ $volsyncData.copyMethod | default "Snapshot"}} + copyMethod: {{ $copyMethod }} capacity: {{ $capacity }} + {{- if eq $copyMethod "Direct" }} + destinationPVC: {{ $objectData.name }} + {{- end }} cleanupTempPVC: {{ $cleanupTempPVC }} cleanupCachePVC: {{ $cleanupCachePVC }} {{- include "tc.v1.common.lib.volsync.storage" (dict "rootCtx" $rootCtx "objectData" $objectData "volsyncData" $volsyncData "target" "dest") | trim | nindent 4 }}