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/04 20:43:40 UTC

[airflow] branch main updated: Runtime class name (#31868)

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 8a6766f0b9 Runtime class name (#31868)
8a6766f0b9 is described below

commit 8a6766f0b95cd270b52117115de48fa328bac18c
Author: Francesco Caronte <ca...@gmail.com>
AuthorDate: Tue Jul 4 22:43:33 2023 +0200

    Runtime class name (#31868)
---
 chart/files/pod-template-file.kubernetes-helm-yaml |  3 +++
 chart/templates/workers/worker-deployment.yaml     |  3 +++
 chart/values.schema.json                           |  8 ++++++++
 chart/values.yaml                                  |  1 +
 tests/charts/airflow_core/test_worker.py           | 10 ++++++++++
 5 files changed, 25 insertions(+)

diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml b/chart/files/pod-template-file.kubernetes-helm-yaml
index 1f3dbc909d..70ac65c8e7 100644
--- a/chart/files/pod-template-file.kubernetes-helm-yaml
+++ b/chart/files/pod-template-file.kubernetes-helm-yaml
@@ -85,6 +85,9 @@ spec:
   {{- if .Values.workers.priorityClassName }}
   priorityClassName: {{ .Values.workers.priorityClassName }}
   {{- end }}
+  {{- if .Values.workers.runtimeClassName }}
+  priorityClassName: {{ .Values.workers.runtimeClassName }}
+  {{- end }}
   {{- if or .Values.registry.secretName .Values.registry.connection }}
   imagePullSecrets:
     - name: {{ template "registry_secret" . }}
diff --git a/chart/templates/workers/worker-deployment.yaml b/chart/templates/workers/worker-deployment.yaml
index bacba8ff03..75b2b1b60a 100644
--- a/chart/templates/workers/worker-deployment.yaml
+++ b/chart/templates/workers/worker-deployment.yaml
@@ -99,6 +99,9 @@ spec:
           {{- toYaml .Values.workers.podAnnotations | nindent 8 }}
         {{- end }}
     spec:
+      {{- if .Values.workers.runtimeClassName }}
+      runtimeClassName: {{ .Values.workers.runtimeClassName }}
+      {{- end }}
       {{- if .Values.workers.priorityClassName }}
       priorityClassName: {{ .Values.workers.priorityClassName }}
       {{- end }}
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 56689532fb..3f9b735679 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -1625,6 +1625,14 @@
                         "type": "string"
                     }
                 },
+                "runtimeClassName": {
+                    "description": "Specify runtime for worker pods.",
+                    "type": [
+                        "string",
+                        "null"
+                    ],
+                    "default": null
+                },
                 "priorityClassName": {
                     "description": "Specify priority for worker pods.",
                     "type": [
diff --git a/chart/values.yaml b/chart/values.yaml
index 3b07b17049..70d862b2fb 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -617,6 +617,7 @@ workers:
 
   # Select certain nodes for airflow worker pods.
   nodeSelector: {}
+  runtimeClassName: ~
   priorityClassName: ~
   affinity: {}
   # default worker affinity is:
diff --git a/tests/charts/airflow_core/test_worker.py b/tests/charts/airflow_core/test_worker.py
index f4e02024a0..f3127b3bdf 100644
--- a/tests/charts/airflow_core/test_worker.py
+++ b/tests/charts/airflow_core/test_worker.py
@@ -378,6 +378,16 @@ class TestWorker:
             docs[0],
         )
 
+    def test_runtime_class_name_values_are_configurable(self):
+        docs = render_chart(
+            values={
+                "workers": {"runtimeClassName": "nvidia"},
+            },
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+
+        assert jmespath.search("spec.template.spec.runtimeClassName", docs[0]) == "nvidia"
+
     def test_livenessprobe_values_are_configurable(self):
         docs = render_chart(
             values={