Skip to content

Commit 38587e9

Browse files
Editable debug mode
1 parent 5ec1f84 commit 38587e9

File tree

3 files changed

+83
-17
lines changed

3 files changed

+83
-17
lines changed

helm/blueapi/templates/statefulset.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,28 @@ spec:
105105
mountPath: {{ .Values.worker.scratch.root }}
106106
mountPropagation: HostToContainer
107107
{{- end }}
108+
{{- if .Values.debug.enabled }}
109+
{{- if not .Values.initContainer.enabled }}
110+
initContainers:
111+
{{- end}}
112+
# add in an init container to copy out virtual environment and workspaces
113+
- name: {{ include "blueapi.fullname" . }}-init-debug
114+
image: "{{ .Values.image.repository }}-debug:{{ .Values.image.tag }}"
115+
imagePullPolicy: IfNotPresent
116+
resources:
117+
{{- .Values.initResources | default .Values.resources | toYaml | nindent 12 }}
118+
{{- with .Values.securityContext }}
119+
securityContext:
120+
{{- toYaml . | nindent 12 }}
121+
{{- end }}
122+
{{- with .Values.initCommand }}
123+
command:
124+
{{- toYaml . | nindent 12 }}
125+
{{- end }}
126+
volumeMounts:
127+
- name: {{ include "blueapi.fullname" . }}-develop
128+
mountPath: /dest
129+
{{- end }}
108130
{{- end }}
109131
containers:
110132
- name: {{ .Chart.Name }}
@@ -147,7 +169,19 @@ spec:
147169
- name: venv
148170
mountPath: /venv
149171
{{- end }}
150-
{{- if or .Values.debug.enabled (and .Values.initContainer.enabled .Values.initContainer.persistentVolume.enabled) }}
172+
{{- if or .Values.debug.enabled }}
173+
- mountPath: /home
174+
name: home
175+
- mountPath: /var/run/nslcd
176+
name: nslcd
177+
- name: {{ include "blueapi.fullname" . }}-develop
178+
mountPath: /workspaces
179+
subPath: workspaces
180+
- name: {{ include "blueapi.fullname" . }}-develop
181+
mountPath: /venv
182+
subPath: venv
183+
{{- end }}
184+
{{- if and .Values.initContainer.enabled .Values.initContainer.persistentVolume.enabled }}
151185
- mountPath: /home
152186
name: home
153187
- mountPath: /var/run/nslcd

helm/blueapi/templates/volumes.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,19 @@ spec:
1212
requests:
1313
storage: 1Gi
1414
{{- end }}
15+
---
16+
# PVC for debugging volume
17+
{{- if .Values.debug.enabled }}
18+
kind: PersistentVolumeClaim
19+
apiVersion: v1
20+
metadata:
21+
name: {{ include "blueapi.fullname" . }}-develop
22+
labels:
23+
app: {{ include "blueapi.fullname" . }}
24+
spec:
25+
accessModes:
26+
- ReadWriteMany
27+
resources:
28+
requests:
29+
storage: "1Gi"
30+
{{- end }}

tests/unit_tests/test_helm_chart.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,10 @@ def test_init_container_venv_volume_mount(
577577
@pytest.mark.parametrize("existingClaimName", [None, "foo"])
578578
@pytest.mark.parametrize("debug_enabled", [True, False])
579579
def test_persistent_volume_claim_exists(
580-
initContainer_enabled,
581-
persistentVolume_enabled,
582-
existingClaimName,
583-
debug_enabled,
580+
initContainer_enabled: bool,
581+
persistentVolume_enabled: bool,
582+
existingClaimName: str | None,
583+
debug_enabled: bool,
584584
):
585585
manifests = render_persistent_volume_chart(
586586
initContainer_enabled,
@@ -589,7 +589,7 @@ def test_persistent_volume_claim_exists(
589589
debug_enabled,
590590
)
591591

592-
persistent_volume_claim = {
592+
scratch_claim = {
593593
"scratch-0.1.0": {
594594
"apiVersion": "v1",
595595
"kind": "PersistentVolumeClaim",
@@ -603,9 +603,26 @@ def test_persistent_volume_claim_exists(
603603
},
604604
}
605605
}
606+
debug_claim = {
607+
"blueapi-develop": {
608+
"apiVersion": "v1",
609+
"kind": "PersistentVolumeClaim",
610+
"metadata": {"labels": {"app": "blueapi"}, "name": "blueapi-develop"},
611+
"spec": {
612+
"accessModes": ["ReadWriteMany"],
613+
"resources": {"requests": {"storage": "1Gi"}},
614+
},
615+
}
616+
}
617+
618+
is_existing_claim = existingClaimName is not None
606619

607-
if persistentVolume_enabled and not existingClaimName:
608-
assert persistent_volume_claim == manifests["PersistentVolumeClaim"]
620+
if (persistentVolume_enabled and not is_existing_claim) and not debug_enabled:
621+
assert scratch_claim == manifests["PersistentVolumeClaim"]
622+
elif not (persistentVolume_enabled and not is_existing_claim) and debug_enabled:
623+
assert debug_claim == manifests["PersistentVolumeClaim"]
624+
elif persistentVolume_enabled and not is_existing_claim and debug_enabled:
625+
assert {**scratch_claim, **debug_claim} == manifests["PersistentVolumeClaim"]
609626
else:
610627
assert "PersistentVolumeClaim" not in manifests
611628

@@ -750,12 +767,12 @@ def test_main_container_venv_volume_mount(
750767
@pytest.mark.parametrize("existingClaimName", [None, "foo"])
751768
@pytest.mark.parametrize("debug_enabled", [True, False])
752769
def test_main_container_home_and_nslcd_volume_mounts(
753-
initContainer_enabled,
754-
persistentVolume_enabled,
755-
existingClaimName,
756-
debug_enabled,
757-
home_volume_mount,
758-
nslcd_volume_mount,
770+
initContainer_enabled: bool,
771+
persistentVolume_enabled: bool,
772+
existingClaimName: str | None,
773+
debug_enabled: bool,
774+
home_volume_mount: dict,
775+
nslcd_volume_mount: dict,
759776
):
760777
manifests = render_persistent_volume_chart(
761778
initContainer_enabled,
@@ -815,8 +832,8 @@ def test_main_container_args(
815832
@pytest.mark.parametrize("existingClaimName", [None, "foo"])
816833
@pytest.mark.parametrize("debug_enabled", [True, False])
817834
def test_scratch_volume_uses_correct_claimName(
818-
existingClaimName,
819-
debug_enabled,
835+
existingClaimName: str | None,
836+
debug_enabled: bool,
820837
):
821838
manifests = render_persistent_volume_chart(
822839
True,
@@ -831,7 +848,6 @@ def test_scratch_volume_uses_correct_claimName(
831848

832849
if existingClaimName:
833850
assert claim_name == existingClaimName
834-
assert "PersistentVolumeClaim" not in manifests
835851
else:
836852
assert claim_name == "scratch-0.1.0"
837853
assert claim_name in manifests["PersistentVolumeClaim"]

0 commit comments

Comments
 (0)