Skip to content

Commit 4b0525f

Browse files
author
wei
committed
fix(falkordb): map backup image by service version
1 parent b55707f commit 4b0525f

4 files changed

Lines changed: 96 additions & 12 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# shellcheck disable=SC2016
3+
4+
Describe "FalkorDB backup image version mapping"
5+
chart_path() {
6+
printf '%s/addons/falkordb\n' "$(cd "${SHELLSPEC_PROJECT_ROOT:-.}" && pwd)"
7+
}
8+
9+
render_template() {
10+
helm template test "$(chart_path)" \
11+
--set image.registry=registry.example.com \
12+
--set image.repository=team/falkordb \
13+
--show-only "templates/$1"
14+
}
15+
16+
It "defers all FalkorDB ActionSet jobs to the backup policy version mapping"
17+
When call render_template backupactionset.yaml
18+
The status should be success
19+
The output should include 'image: $(FALKORDB_IMAGE)'
20+
The output should not include 'registry.example.com/team/falkordb:'
21+
The output should satisfy awk '
22+
/image: \$\(FALKORDB_IMAGE\)/ { mapped++ }
23+
END { exit mapped == 9 ? 0 : 1 }
24+
'
25+
End
26+
27+
It "maps standalone datafile and PITR jobs to every service version image"
28+
When call render_template backuppolicytemplate.yaml
29+
The status should be success
30+
The output should satisfy awk '
31+
/name: FALKORDB_IMAGE/ { names++ }
32+
/mappedValue: registry.example.com\/team\/falkordb:v4.12.5/ { v412++ }
33+
/mappedValue: registry.example.com\/team\/falkordb:v4.14.12/ { v414++ }
34+
END { exit names == 2 && v412 == 2 && v414 == 2 ? 0 : 1 }
35+
'
36+
End
37+
38+
It "maps cluster datafile jobs to every service version image"
39+
When call render_template backuppolicytemplateforcluster.yaml
40+
The status should be success
41+
The output should satisfy awk '
42+
/name: FALKORDB_IMAGE/ { names++ }
43+
/mappedValue: registry.example.com\/team\/falkordb:v4.12.5/ { v412++ }
44+
/mappedValue: registry.example.com\/team\/falkordb:v4.14.12/ { v414++ }
45+
END { exit names == 1 && v412 == 1 && v414 == 1 ? 0 : 1 }
46+
'
47+
End
48+
End

addons/falkordb/templates/backupactionset.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
preBackup: []
1717
postBackup: []
1818
backupData:
19-
image: {{ include "falkordb4.image" . }}
19+
image: $(FALKORDB_IMAGE)
2020
runOnTargetPodNode: true
2121
syncProgress:
2222
enabled: true
@@ -28,7 +28,7 @@ spec:
2828
{{- .Files.Get "dataprotection/backup.sh" | nindent 8 }}
2929
restore:
3030
prepareData:
31-
image: {{ include "falkordb4.image" . }}
31+
image: $(FALKORDB_IMAGE)
3232
command:
3333
- bash
3434
- -c
@@ -42,7 +42,7 @@ spec:
4242
- -c
4343
- |
4444
{{- .Files.Get "dataprotection/restore-keys.sh" | nindent 10 }}
45-
image: {{ include "falkordb4.image" . }}
45+
image: $(FALKORDB_IMAGE)
4646
onError: Fail
4747
runOnTargetPodNode: true
4848
---
@@ -66,7 +66,7 @@ spec:
6666
preBackup: []
6767
postBackup: []
6868
backupData:
69-
image: {{ include "falkordb4.image" . }}
69+
image: $(FALKORDB_IMAGE)
7070
runOnTargetPodNode: true
7171
syncProgress:
7272
enabled: true
@@ -78,7 +78,7 @@ spec:
7878
{{- .Files.Get "dataprotection/backup.sh" | nindent 8 }}
7979
restore:
8080
prepareData:
81-
image: {{ include "falkordb4.image" . }}
81+
image: $(FALKORDB_IMAGE)
8282
command:
8383
- bash
8484
- -c
@@ -91,7 +91,7 @@ spec:
9191
- -c
9292
- |
9393
{{- .Files.Get "dataprotection/wait-for-cluster-ready.sh" | nindent 10 }}
94-
image: {{ include "falkordb4.image" . }}
94+
image: $(FALKORDB_IMAGE)
9595
onError: Fail
9696
runOnTargetPodNode: true
9797
- job:
@@ -124,7 +124,7 @@ spec:
124124
preBackup: []
125125
postBackup: []
126126
backupData:
127-
image: {{ include "falkordb4.image" . }}
127+
image: $(FALKORDB_IMAGE)
128128
runOnTargetPodNode: true
129129
syncProgress:
130130
enabled: true
@@ -138,7 +138,7 @@ spec:
138138
{{- .Files.Get "dataprotection/pitr-backup.sh" | nindent 8 }}
139139
restore:
140140
prepareData:
141-
image: {{ include "falkordb4.image" . }}
141+
image: $(FALKORDB_IMAGE)
142142
command:
143143
- bash
144144
- -c
@@ -154,7 +154,7 @@ spec:
154154
- -c
155155
- |
156156
{{- .Files.Get "dataprotection/restore-keys.sh" | nindent 10 }}
157-
image: {{ include "falkordb4.image" . }}
157+
image: $(FALKORDB_IMAGE)
158158
onError: Fail
159159
runOnTargetPodNode: true
160160
baseBackupRequired: false
@@ -192,4 +192,4 @@ spec:
192192
- sh
193193
- -c
194194
- |
195-
{{- .Files.Get "dataprotection/restore-cluster-users.sh" | nindent 8 }}
195+
{{- .Files.Get "dataprotection/restore-cluster-users.sh" | nindent 8 }}

addons/falkordb/templates/backuppolicytemplate.yaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,37 @@ spec:
2020
volumeMounts:
2121
- name: data
2222
mountPath: {{ .Values.dataMountPath }}
23+
env:
24+
- name: FALKORDB_IMAGE
25+
valueFrom:
26+
versionMapping:
27+
{{- $repository := printf "%s/%s" (.Values.image.registry | default "docker.io") .Values.image.repository }}
28+
{{- range .Values.falkordbVersions }}
29+
{{- range .mirrorVersions }}
30+
- serviceVersions:
31+
- {{ .version }}
32+
mappedValue: {{ $repository }}:{{ .imageTag }}
33+
{{- end }}
34+
{{- end }}
2335
- name: aof
2436
snapshotVolumes: false
2537
actionSetName: falkordb-for-pitr
2638
targetVolumes:
2739
volumeMounts:
2840
- name: data
2941
mountPath: {{ .Values.dataMountPath }}
42+
env:
43+
- name: FALKORDB_IMAGE
44+
valueFrom:
45+
versionMapping:
46+
{{- $repository := printf "%s/%s" (.Values.image.registry | default "docker.io") .Values.image.repository }}
47+
{{- range .Values.falkordbVersions }}
48+
{{- range .mirrorVersions }}
49+
- serviceVersions:
50+
- {{ .version }}
51+
mappedValue: {{ $repository }}:{{ .imageTag }}
52+
{{- end }}
53+
{{- end }}
3054
- name: volume-snapshot
3155
snapshotVolumes: true
3256
targetVolumes:
@@ -53,4 +77,4 @@ spec:
5377
- backupMethod: volume-snapshot
5478
enabled: false
5579
cronExpression: "0 18 * * 0"
56-
retentionPeriod: 7d
80+
retentionPeriod: 7d

addons/falkordb/templates/backuppolicytemplateforcluster.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ spec:
2020
volumeMounts:
2121
- name: data
2222
mountPath: {{ .Values.dataMountPath }}
23+
env:
24+
- name: FALKORDB_IMAGE
25+
valueFrom:
26+
versionMapping:
27+
{{- $repository := printf "%s/%s" (.Values.image.registry | default "docker.io") .Values.image.repository }}
28+
{{- range .Values.falkordbVersions }}
29+
{{- range .mirrorVersions }}
30+
- serviceVersions:
31+
- {{ .version }}
32+
mappedValue: {{ $repository }}:{{ .imageTag }}
33+
{{- end }}
34+
{{- end }}
2335
- name: backup-for-rebuild-instance
2436
actionSetName: falkordb-for-rebuild-instance
2537
env:
@@ -39,4 +51,4 @@ spec:
3951
- backupMethod: datafile
4052
enabled: false
4153
cronExpression: "0 18 * * 0"
42-
retentionPeriod: 7d
54+
retentionPeriod: 7d

0 commit comments

Comments
 (0)