Skip to content

Commit 78ece56

Browse files
committed
Fix priorityClassName for migrator and executors charts
1 parent 5dfb205 commit 78ece56

File tree

7 files changed

+45
-13
lines changed

7 files changed

+45
-13
lines changed

TEST.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ helm plugin install https://github.com/helm-unittest/helm-unittest
2323
Once the plugin is installed, you can run the unit tests using the following:
2424

2525
```bash
26-
helm unittest ./charts/sourcegraph/.
26+
helm unittest ./charts/sourcegraph
2727
```
2828

2929
We currently do not have testing best practices or require unit tests for new changes, so add test cases at your best judgement if possible.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{/*
2+
3+
Allow customers to assign a priorityClassName to all resources which create pods (ex. DaemonSets, Deployments, StatefulSets)
4+
5+
Customers can configure an instance-wide default priorty class name at .Values.sourcegraph.priorityClassName,
6+
and can override it for individual services, if needed, at .Values.<service>.priorityClassName
7+
8+
*/}}
9+
10+
{{- define "sourcegraph.priorityClassName" -}}
11+
{{- $top := index . 0 }}
12+
{{- $service := index . 1 }}
13+
{{- $globalPriorityClassName := (index $top.Values "sourcegraph" "priorityClassName") }}
14+
{{- $servicePriorityClassName := (index $top.Values $service "priorityClassName") }}
15+
{{- if $servicePriorityClassName }}
16+
priorityClassName: {{ $servicePriorityClassName | toYaml | trim }}
17+
{{- else if $globalPriorityClassName }}
18+
priorityClassName: {{ $globalPriorityClassName | toYaml | trim }}
19+
{{- end }}
20+
{{- end }}

charts/sourcegraph-executor/dind/templates/executor/executor.Deployment.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ spec:
130130
affinity:
131131
{{- toYaml . | nindent 8 }}
132132
{{- end }}
133+
{{- with include "sourcegraph.priorityClassName" (list . "executor") | trim }}{{ . | nindent 6 }}{{- end }}
133134
{{- with .Values.sourcegraph.tolerations }}
134-
{{- if or .Values.executor.priorityClassName .Values.sourcegraph.priorityClassName }}
135-
priorityClassName: {{ coalesce .Values.executor.priorityClassName .Values.sourcegraph.priorityClassName }}
136-
{{- end }}
137135
tolerations:
138136
{{- toYaml . | nindent 8 }}
139137
{{- end }}

charts/sourcegraph-executor/dind/templates/private-docker-registry/private-docker-registry.Deployment.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ spec:
7474
affinity:
7575
{{- toYaml . | nindent 8 }}
7676
{{- end }}
77+
{{- with include "sourcegraph.priorityClassName" (list . "privateDockerRegistry") | trim }}{{ . | nindent 6 }}{{- end }}
7778
{{- with .Values.sourcegraph.tolerations }}
78-
{{- if or .Values.privateDockerRegistry.priorityClassName .Values.sourcegraph.priorityClassName }}
79-
priorityClassName: {{ coalesce .Values.privateDockerRegistry.priorityClassName .Values.sourcegraph.priorityClassName }}
80-
{{- end }}
8179
tolerations:
8280
{{- toYaml . | nindent 8 }}
8381
{{- end }}

charts/sourcegraph-executor/k8s/templates/executor.Deployment.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ spec:
9999
affinity:
100100
{{- toYaml . | nindent 8 }}
101101
{{- end }}
102+
{{- with include "sourcegraph.priorityClassName" (list . "executor") | trim }}{{ . | nindent 6 }}{{- end }}
102103
{{- with .Values.executor.tolerations }}
103-
{{- if or .Values.executor.priorityClassName .Values.sourcegraph.priorityClassName }}
104-
priorityClassName: {{ coalesce .Values.executor.priorityClassName .Values.sourcegraph.priorityClassName }}
105-
{{- end }}
106104
tolerations:
107105
{{- toYaml . | nindent 8 }}
108106
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{/*
2+
3+
Allow customers to assign a priorityClassName to all resources which create pods (ex. DaemonSets, Deployments, StatefulSets)
4+
5+
Customers can configure an instance-wide default priorty class name at .Values.sourcegraph.priorityClassName,
6+
and can override it for individual services, if needed, at .Values.<service>.priorityClassName
7+
8+
*/}}
9+
10+
{{- define "sourcegraph.priorityClassName" -}}
11+
{{- $top := index . 0 }}
12+
{{- $service := index . 1 }}
13+
{{- $globalPriorityClassName := (index $top.Values "sourcegraph" "priorityClassName") }}
14+
{{- $servicePriorityClassName := (index $top.Values $service "priorityClassName") }}
15+
{{- if $servicePriorityClassName }}
16+
priorityClassName: {{ $servicePriorityClassName | toYaml | trim }}
17+
{{- else if $globalPriorityClassName }}
18+
priorityClassName: {{ $globalPriorityClassName | toYaml | trim }}
19+
{{- end }}
20+
{{- end }}

charts/sourcegraph-migrator/templates/migrator/sourcegraph-migrator.Job.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ spec:
6868
affinity:
6969
{{- toYaml . | nindent 8 }}
7070
{{- end }}
71+
{{- with include "sourcegraph.priorityClassName" (list . "migrator") | trim }}{{ . | nindent 6 }}{{- end }}
7172
{{- with .Values.sourcegraph.tolerations }}
72-
{{- if or .Values.migrator.priorityClassName .Values.sourcegraph.priorityClassName }}
73-
priorityClassName: {{ coalesce .Values.migrator.priorityClassName .Values.sourcegraph.priorityClassName }}
74-
{{- end }}
7573
tolerations:
7674
{{- toYaml . | nindent 8 }}
7775
{{- end }}

0 commit comments

Comments
 (0)