Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions chart/templates/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ spec:
imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
securityContext: {{ $containerSecurityContextWaitForMigrations | nindent 12 }}
volumeMounts:
- name: logs
mountPath: "/opt/airflow/logs"
{{- if .Values.logs.persistence.subPath }}
subPath: {{ .Values.logs.persistence.subPath }}
{{- end }}
{{- include "airflow_config_mount" . | nindent 12 }}
{{- if .Values.volumeMounts }}
{{- toYaml .Values.volumeMounts | nindent 12 }}
Expand Down
5 changes: 5 additions & 0 deletions chart/templates/triggerer/triggerer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ spec:
imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
securityContext: {{ $containerSecurityContextWaitForMigrations | nindent 12 }}
volumeMounts:
- name: logs
mountPath: "/opt/airflow/logs"
{{- if .Values.logs.persistence.subPath }}
subPath: {{ .Values.logs.persistence.subPath }}
{{- end }}
{{- include "airflow_config_mount" . | nindent 12 }}
{{- if .Values.volumeMounts }}
{{- toYaml .Values.volumeMounts | nindent 12 }}
Expand Down
5 changes: 5 additions & 0 deletions chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ spec:
imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
securityContext: {{ $containerSecurityContextWaitForMigrations | nindent 12 }}
volumeMounts:
- name: logs
mountPath: "/opt/airflow/logs"
{{- if .Values.logs.persistence.subPath }}
subPath: {{ .Values.logs.persistence.subPath }}
{{- end }}
{{- include "airflow_config_mount" . | nindent 12 }}
{{- if .Values.volumeMounts }}
{{- toYaml .Values.volumeMounts | nindent 12 }}
Expand Down
31 changes: 31 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,37 @@ def test_disable_wait_for_migration(self):
)
assert actual is None

@pytest.mark.parametrize(
("logs_values", "expect_sub_path"),
[
({"persistence": {"enabled": False}}, None),
({"persistence": {"enabled": True, "subPath": "test/logs"}}, "test/logs"),
],
)
def test_logs_mount_on_wait_for_migrations_initcontainer(self, logs_values, expect_sub_path):
docs = render_chart(
values={
"logs": logs_values,
},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
)

mounts = jmespath.search(
"spec.template.spec.initContainers[?name=='wait-for-airflow-migrations'] | [0].volumeMounts",
docs[0],
)
assert mounts is not None, (
"wait-for-airflow-migrations initContainer not found or has no volumeMounts"
)
assert any(m.get("name") == "logs" and m.get("mountPath") == "/opt/airflow/logs" for m in mounts)
if expect_sub_path is not None:
assert any(
m.get("name") == "logs"
and m.get("mountPath") == "/opt/airflow/logs"
and m.get("subPath") == expect_sub_path
for m in mounts
)

def test_should_add_extra_init_containers(self):
docs = render_chart(
values={
Expand Down
32 changes: 32 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_triggerer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,38 @@ def test_disable_wait_for_migration(self):
)
assert actual is None

@pytest.mark.parametrize(
("logs_values", "expect_sub_path"),
[
({"persistence": {"enabled": False}}, None),
({"persistence": {"enabled": True, "subPath": "test/logs"}}, "test/logs"),
],
)
def test_logs_mount_on_wait_for_migrations_initcontainer(self, logs_values, expect_sub_path):
docs = render_chart(
values={
"logs": logs_values,
"triggerer": {"enabled": True},
},
show_only=["templates/triggerer/triggerer-deployment.yaml"],
)

mounts = jmespath.search(
"spec.template.spec.initContainers[?name=='wait-for-airflow-migrations'] | [0].volumeMounts",
docs[0],
)
assert mounts is not None, (
"wait-for-airflow-migrations initContainer not found or has no volumeMounts"
)
assert any(m.get("name") == "logs" and m.get("mountPath") == "/opt/airflow/logs" for m in mounts)
if expect_sub_path is not None:
assert any(
m.get("name") == "logs"
and m.get("mountPath") == "/opt/airflow/logs"
and m.get("subPath") == expect_sub_path
for m in mounts
)

def test_should_add_extra_containers(self):
docs = render_chart(
values={
Expand Down
32 changes: 32 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,38 @@ def test_disable_wait_for_migration(self):
)
assert actual is None

@pytest.mark.parametrize(
("logs_values", "expect_sub_path"),
[
({"persistence": {"enabled": False}}, None),
({"persistence": {"enabled": True, "subPath": "test/logs"}}, "test/logs"),
],
)
def test_logs_mount_on_wait_for_migrations_initcontainer(self, logs_values, expect_sub_path):
docs = render_chart(
values={
"executor": "CeleryExecutor",
"logs": logs_values,
},
show_only=["templates/workers/worker-deployment.yaml"],
)

mounts = jmespath.search(
"spec.template.spec.initContainers[?name=='wait-for-airflow-migrations'] | [0].volumeMounts",
docs[0],
)
assert mounts is not None, (
"wait-for-airflow-migrations initContainer not found or has no volumeMounts"
)
assert any(m.get("name") == "logs" and m.get("mountPath") == "/opt/airflow/logs" for m in mounts)
if expect_sub_path is not None:
assert any(
m.get("name") == "logs"
and m.get("mountPath") == "/opt/airflow/logs"
and m.get("subPath") == expect_sub_path
for m in mounts
)

def test_should_add_extra_init_containers(self):
docs = render_chart(
values={
Expand Down