Skip to content

Commit 693f67a

Browse files
authored
fix: Support multiple blueapi instances in a namespace #1262 (#1265)
Make persistent volume claims unique for each instance by prefixing each scratch name with blueapi.fullname helper.
1 parent e1d4b58 commit 693f67a

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

helm/blueapi/templates/statefulset.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ spec:
6060
{{- if .Values.initContainer.persistentVolume.enabled }}
6161
- name: scratch
6262
persistentVolumeClaim:
63-
claimName: {{default (tpl "scratch-{{ .Values.image.tag | default .Chart.AppVersion }}" .) .Values.initContainer.persistentVolume.existingClaimName }}
63+
{{- if .Values.initContainer.persistentVolume.existingClaimName }}
64+
claimName: {{ .Values.initContainer.persistentVolume.existingClaimName }}
65+
{{- else }}
66+
claimName: {{ include "blueapi.fullname" . }}-scratch-{{ .Values.image.tag | default .Chart.AppVersion }}
67+
{{- end }}
6468
{{- else }}
6569
- name: scratch-host
6670
hostPath:

helm/blueapi/templates/volumes.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: PersistentVolumeClaim
44
metadata:
5-
name: scratch-{{ .Values.image.tag | default .Chart.AppVersion }}
5+
name: {{ include "blueapi.fullname" . }}-scratch-{{ .Values.image.tag | default .Chart.AppVersion }}
66
annotations:
77
helm.sh/resource-policy: keep
88
spec:

tests/unit_tests/test_helm_chart.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,11 @@ def test_persistent_volume_claim_exists(
593593
)
594594

595595
persistent_volume_claim = {
596-
"scratch-0.1.0": {
596+
"blueapi-scratch-0.1.0": {
597597
"apiVersion": "v1",
598598
"kind": "PersistentVolumeClaim",
599599
"metadata": {
600-
"name": "scratch-0.1.0",
600+
"name": "blueapi-scratch-0.1.0",
601601
"annotations": {"helm.sh/resource-policy": "keep"},
602602
},
603603
"spec": {
@@ -836,7 +836,7 @@ def test_scratch_volume_uses_correct_name(
836836
assert claim_name == existing_claim_name
837837
assert "PersistentVolumeClaim" not in manifests
838838
else:
839-
assert claim_name == "scratch-0.1.0"
839+
assert claim_name == "blueapi-scratch-0.1.0"
840840
assert claim_name in manifests["PersistentVolumeClaim"]
841841

842842

0 commit comments

Comments
 (0)