Skip to content

Commit

Permalink
Chart: Support workers.command for KubernetesExecutor (#39132)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyirit authored Apr 23, 2024
1 parent b365cbd commit 6e51198
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ spec:
lifecycle: {{- tpl (toYaml $containerLifecycleHooks) . | nindent 8 }}
{{- end }}
name: base
{{- if .Values.workers.command }}
command: {{ tpl (toYaml .Values.workers.command) . | nindent 8 }}
{{- end }}
resources: {{- toYaml .Values.workers.resources | nindent 8 }}
volumeMounts:
- mountPath: {{ template "airflow_logs" . }}
Expand Down
36 changes: 36 additions & 0 deletions helm_tests/airflow_aux/test_pod_template_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,3 +900,39 @@ def test_airflow_kerberos_init_container(
if expected_init_containers == 1:
assert initContainers[0]["name"] == "kerberos-init"
assert initContainers[0]["args"] == ["kerberos", "-o"]

@pytest.mark.parametrize(
"cmd, expected",
[
(["test", "command", "to", "run"], ["test", "command", "to", "run"]),
(["cmd", "{{ .Release.Name }}"], ["cmd", "release-name"]),
],
)
def test_should_add_command(self, cmd, expected):
docs = render_chart(
values={
"workers": {"command": cmd},
},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert expected == jmespath.search("spec.containers[0].command", docs[0])

@pytest.mark.parametrize("cmd", [None, []])
def test_should_not_add_command(self, cmd):
docs = render_chart(
values={"workers": {"command": cmd}},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert None is jmespath.search("spec.containers[0].command", docs[0])

def test_should_not_add_command_by_default(self):
docs = render_chart(
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert None is jmespath.search("spec.containers[0].command", docs[0])

0 comments on commit 6e51198

Please sign in to comment.