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

husseinawala 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 6f51e502df Add annotations field into  in KubernetesPodOperator 
(#35641)
6f51e502df is described below

commit 6f51e502df42e0695950bd0af681b7497b8bc6fc
Author: shohamy7 <[email protected]>
AuthorDate: Wed Nov 15 21:36:20 2023 +0200

    Add annotations field into  in KubernetesPodOperator (#35641)
---
 airflow/providers/cncf/kubernetes/operators/pod.py    | 3 ++-
 tests/providers/cncf/kubernetes/operators/test_pod.py | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/airflow/providers/cncf/kubernetes/operators/pod.py 
b/airflow/providers/cncf/kubernetes/operators/pod.py
index 58e54a72d3..3cacb126d0 100644
--- a/airflow/providers/cncf/kubernetes/operators/pod.py
+++ b/airflow/providers/cncf/kubernetes/operators/pod.py
@@ -191,7 +191,7 @@ class KubernetesPodOperator(BaseOperator):
     :param image_pull_policy: Specify a policy to cache or always pull an 
image.
     :param annotations: non-identifying metadata you can attach to the Pod.
         Can be a large range of data, and can include characters
-        that are not permitted by labels.
+        that are not permitted by labels. (templated)
     :param container_resources: resources for the launched pod. (templated)
     :param affinity: affinity scheduling rules for the launched pod.
     :param config_file: The path to the Kubernetes config file. (templated)
@@ -261,6 +261,7 @@ class KubernetesPodOperator(BaseOperator):
     template_fields: Sequence[str] = (
         "image",
         "cmds",
+        "annotations",
         "arguments",
         "env_vars",
         "labels",
diff --git a/tests/providers/cncf/kubernetes/operators/test_pod.py 
b/tests/providers/cncf/kubernetes/operators/test_pod.py
index ae49d7fe7d..5e9cbbb916 100644
--- a/tests/providers/cncf/kubernetes/operators/test_pod.py
+++ b/tests/providers/cncf/kubernetes/operators/test_pod.py
@@ -149,6 +149,7 @@ class TestKubernetesPodOperator:
             arguments="{{ dag.dag_id }}",
             cmds="{{ dag.dag_id }}",
             image="{{ dag.dag_id }}",
+            annotations={"dag-id": "{{ dag.dag_id }}"},
         )
 
         rendered = ti.render_templates()
@@ -167,6 +168,7 @@ class TestKubernetesPodOperator:
         assert dag_id == ti.task.pod_template_file
         assert dag_id == ti.task.arguments
         assert dag_id == ti.task.env_vars[0]
+        assert dag_id == rendered.annotations["dag-id"]
 
     def run_pod(self, operator: KubernetesPodOperator, map_index: int = -1) -> 
k8s.V1Pod:
         with self.dag_maker(dag_id="dag") as dag:

Reply via email to