You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/07/11 17:35:24 UTC

[airflow] branch main updated: BugFix: Using `json` string in template_field causes issue with K8s Operators (#16930)

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

kaxilnaik 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 b2c66e4  BugFix: Using `json` string in template_field causes issue with K8s Operators (#16930)
b2c66e4 is described below

commit b2c66e45b7c27d187491ec6a1dd5cc92ac7a1e32
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Sun Jul 11 18:35:04 2021 +0100

    BugFix: Using `json` string in template_field causes issue with K8s Operators (#16930)
    
    closes https://github.com/apache/airflow/issues/16922
    
    Because we simply check if fields in template_field ends with `template_ext`,
    this was causing issues if the str ends with json, in which case Airflow would
    try to search for file instead of using the string
---
 airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py   | 2 +-
 airflow/providers/cncf/kubernetes/operators/spark_kubernetes.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
index 7e6cef2..32ce4dc 100644
--- a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
+++ b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
@@ -172,7 +172,7 @@ class KubernetesPodOperator(BaseOperator):
         'pod_template_file',
     )
 
-    template_ext = ('yaml', 'yml', 'json')
+    template_ext = ('.yaml', '.yml', '.json')
 
     # fmt: off
     def __init__(
diff --git a/airflow/providers/cncf/kubernetes/operators/spark_kubernetes.py b/airflow/providers/cncf/kubernetes/operators/spark_kubernetes.py
index 1e1fa5f..ef33854 100644
--- a/airflow/providers/cncf/kubernetes/operators/spark_kubernetes.py
+++ b/airflow/providers/cncf/kubernetes/operators/spark_kubernetes.py
@@ -43,7 +43,7 @@ class SparkKubernetesOperator(BaseOperator):
     """
 
     template_fields = ['application_file', 'namespace']
-    template_ext = ('yaml', 'yml', 'json')
+    template_ext = ('.yaml', '.yml', '.json')
     ui_color = '#f4a460'
 
     def __init__(