You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by je...@apache.org on 2023/01/10 23:52:52 UTC

[airflow] branch main updated: Add worker service account for LocalKubernetesExecutor (#28813)

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

jedcunningham 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 8f933c99c1 Add worker service account for LocalKubernetesExecutor (#28813)
8f933c99c1 is described below

commit 8f933c99c18bea9ce5651802fdc7d65060e372b6
Author: Oliver Chen <ol...@gmail.com>
AuthorDate: Tue Jan 10 15:52:40 2023 -0800

    Add worker service account for LocalKubernetesExecutor (#28813)
---
 chart/templates/workers/worker-serviceaccount.yaml |  2 +-
 tests/charts/test_worker.py                        | 30 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/chart/templates/workers/worker-serviceaccount.yaml b/chart/templates/workers/worker-serviceaccount.yaml
index bebddb96be..e55d5d511a 100644
--- a/chart/templates/workers/worker-serviceaccount.yaml
+++ b/chart/templates/workers/worker-serviceaccount.yaml
@@ -18,7 +18,7 @@
 ################################
 ## Airflow Worker ServiceAccount
 #################################
-{{- if and .Values.workers.serviceAccount.create (or (eq .Values.executor "CeleryExecutor") (eq .Values.executor "CeleryKubernetesExecutor") (eq .Values.executor "KubernetesExecutor")) }}
+{{- if and .Values.workers.serviceAccount.create (or (eq .Values.executor "CeleryExecutor") (eq .Values.executor "CeleryKubernetesExecutor") (eq .Values.executor "KubernetesExecutor") (eq .Values.executor "LocalKubernetesExecutor")) }}
 kind: ServiceAccount
 apiVersion: v1
 metadata:
diff --git a/tests/charts/test_worker.py b/tests/charts/test_worker.py
index 39c65cf87a..76a511a389 100644
--- a/tests/charts/test_worker.py
+++ b/tests/charts/test_worker.py
@@ -758,3 +758,33 @@ class TestWorkerServiceAccount:
 
         assert "test_label" in jmespath.search("metadata.labels", docs[0])
         assert jmespath.search("metadata.labels", docs[0])["test_label"] == "test_label_value"
+
+    @pytest.mark.parametrize(
+        "executor, creates_service_account",
+        [
+            ("LocalExecutor", False),
+            ("CeleryExecutor", True),
+            ("CeleryKubernetesExecutor", True),
+            ("KubernetesExecutor", True),
+            ("LocalKubernetesExecutor", True),
+        ],
+    )
+    def test_should_create_worker_service_account_for_specific_executors(
+        self, executor, creates_service_account
+    ):
+        docs = render_chart(
+            values={
+                "executor": executor,
+                "workers": {
+                    "serviceAccount": {"create": True},
+                    "labels": {"test_label": "test_label_value"},
+                },
+            },
+            show_only=["templates/workers/worker-serviceaccount.yaml"],
+        )
+        if creates_service_account:
+            assert jmespath.search("kind", docs[0]) == "ServiceAccount"
+            assert "test_label" in jmespath.search("metadata.labels", docs[0])
+            assert jmespath.search("metadata.labels", docs[0])["test_label"] == "test_label_value"
+        else:
+            assert docs == []