You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/07/09 06:25:16 UTC

[airflow] branch main updated: fix(helm): dagprocessor livenessProbe include --local and --job-type args (#32426)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new d27532b21a fix(helm): dagprocessor livenessProbe include --local and --job-type args (#32426)
d27532b21a is described below

commit d27532b21abd3db9695a66d1df783babe872d856
Author: Detlev V <de...@protonmail.com>
AuthorDate: Sun Jul 9 08:25:09 2023 +0200

    fix(helm): dagprocessor livenessProbe include --local and --job-type args (#32426)
    
    
    
    ---------
    
    Co-authored-by: Detlev Vandaele <de...@Detlevs-MacBook-Pro.local>
---
 chart/templates/_helpers.yaml                 | 13 +++++++++++--
 helm_tests/airflow_core/test_dag_processor.py | 18 ++++++++++++++++++
 helm_tests/airflow_core/test_scheduler.py     | 18 ++++++++++++++++++
 helm_tests/airflow_core/test_triggerer.py     | 17 +++++++++++++++++
 4 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/chart/templates/_helpers.yaml b/chart/templates/_helpers.yaml
index 651dfa6914..fc805e56b5 100644
--- a/chart/templates/_helpers.yaml
+++ b/chart/templates/_helpers.yaml
@@ -690,16 +690,25 @@ server_tls_key_file = /etc/pgbouncer/server.key
   - -c
   - |
     CONNECTION_CHECK_MAX_COUNT=0 AIRFLOW__LOGGING__LOGGING_LEVEL=ERROR exec /entrypoint \
-    airflow jobs check --job-type TriggererJob  --hostname $(hostname)
+    airflow jobs check --job-type TriggererJob --hostname $(hostname)
   {{- end }}
 {{- end }}
 
 {{- define "dag_processor_liveness_check_command" }}
+  {{- $commandArgs := (list) -}}
+  {{- if semverCompare ">=2.5.0" .Values.airflowVersion }}
+    {{- $commandArgs = append $commandArgs "--local" -}}
+    {{- if semverCompare ">=2.5.2" .Values.airflowVersion }}
+      {{- $commandArgs = concat $commandArgs (list "--job-type" "DagProcessorJob") -}}
+    {{- end }}
+  {{- else }}
+    {{- $commandArgs = concat $commandArgs (list "--hostname" "$(hostname)") -}}
+  {{- end }}
   - sh
   - -c
   - |
     CONNECTION_CHECK_MAX_COUNT=0 AIRFLOW__LOGGING__LOGGING_LEVEL=ERROR exec /entrypoint \
-    airflow jobs check --hostname $(hostname)
+    airflow jobs check {{ join " " $commandArgs }}
 {{- end }}
 
 {{- define "registry_docker_config" }}
diff --git a/helm_tests/airflow_core/test_dag_processor.py b/helm_tests/airflow_core/test_dag_processor.py
index dbde3f7b33..c25fea08ab 100644
--- a/helm_tests/airflow_core/test_dag_processor.py
+++ b/helm_tests/airflow_core/test_dag_processor.py
@@ -338,6 +338,24 @@ class TestDagProcessor:
             "spec.template.spec.containers[0].livenessProbe.exec.command", docs[0]
         )
 
+    @pytest.mark.parametrize(
+        "airflow_version, probe_command",
+        [
+            ("2.4.9", "airflow jobs check --hostname $(hostname)"),
+            ("2.5.0", "airflow jobs check --local"),
+            ("2.5.2", "airflow jobs check --local --job-type DagProcessorJob"),
+        ],
+    )
+    def test_livenessprobe_command_depends_on_airflow_version(self, airflow_version, probe_command):
+        docs = render_chart(
+            values={"airflowVersion": f"{airflow_version}", "dagProcessor": {"enabled": True}},
+            show_only=["templates/dag-processor/dag-processor-deployment.yaml"],
+        )
+        assert (
+            probe_command
+            in jmespath.search("spec.template.spec.containers[0].livenessProbe.exec.command", docs[0])[-1]
+        )
+
     @pytest.mark.parametrize(
         "log_persistence_values, expected_volume",
         [
diff --git a/helm_tests/airflow_core/test_scheduler.py b/helm_tests/airflow_core/test_scheduler.py
index faf666854b..698ba4f6eb 100644
--- a/helm_tests/airflow_core/test_scheduler.py
+++ b/helm_tests/airflow_core/test_scheduler.py
@@ -357,6 +357,24 @@ class TestScheduler:
             "spec.template.spec.containers[0].livenessProbe.exec.command", docs[0]
         )
 
+    @pytest.mark.parametrize(
+        "airflow_version, probe_command",
+        [
+            ("1.9.0", "from airflow.jobs.scheduler_job import SchedulerJob"),
+            ("2.1.0", "airflow jobs check --job-type SchedulerJob --hostname $(hostname)"),
+            ("2.5.0", "airflow jobs check --job-type SchedulerJob --local"),
+        ],
+    )
+    def test_livenessprobe_command_depends_on_airflow_version(self, airflow_version, probe_command):
+        docs = render_chart(
+            values={"airflowVersion": f"{airflow_version}"},
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
+        )
+        assert (
+            probe_command
+            in jmespath.search("spec.template.spec.containers[0].livenessProbe.exec.command", docs[0])[-1]
+        )
+
     @pytest.mark.parametrize(
         "log_persistence_values, expected_volume",
         [
diff --git a/helm_tests/airflow_core/test_triggerer.py b/helm_tests/airflow_core/test_triggerer.py
index 0154c8f8c0..22a8ad7f52 100644
--- a/helm_tests/airflow_core/test_triggerer.py
+++ b/helm_tests/airflow_core/test_triggerer.py
@@ -359,6 +359,23 @@ class TestTriggerer:
             "spec.template.spec.containers[0].livenessProbe.exec.command", docs[0]
         )
 
+    @pytest.mark.parametrize(
+        "airflow_version, probe_command",
+        [
+            ("2.4.9", "airflow jobs check --job-type TriggererJob --hostname $(hostname)"),
+            ("2.5.0", "airflow jobs check --job-type TriggererJob --local"),
+        ],
+    )
+    def test_livenessprobe_command_depends_on_airflow_version(self, airflow_version, probe_command):
+        docs = render_chart(
+            values={"airflowVersion": f"{airflow_version}"},
+            show_only=["templates/triggerer/triggerer-deployment.yaml"],
+        )
+        assert (
+            probe_command
+            in jmespath.search("spec.template.spec.containers[0].livenessProbe.exec.command", docs[0])[-1]
+        )
+
     @pytest.mark.parametrize(
         "log_persistence_values, expected_volume",
         [