From f3d5c61123202e85369ce6574e39bb214bebfb65 Mon Sep 17 00:00:00 2001 From: Kaxil Naik Date: Sun, 11 Jul 2021 18:35:04 +0100 Subject: [PATCH] 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 GitOrigin-RevId: b2c66e45b7c27d187491ec6a1dd5cc92ac7a1e32 --- 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 7e6cef2b5a4..32ce4dc0ace 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 1e1fa5fbd69..ef338540031 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__(