Alxander64 opened a new issue #16125:
URL: https://github.com/apache/airflow/issues/16125
**Apache Airflow version**: v2.0.1
**Kubernetes version (if you are using kubernetes)** (use `kubectl
version`): 1.16
**Environment**: Kubernetes (EKS)
- **Cloud provider or hardware configuration**: AWS
- **OS** (e.g. from /etc/os-release):
- **Kernel** (e.g. `uname -a`):
- **Install tools**: Helm
- **Others**:
**What happened**:
Using task instance of KubernetesPodOperator as shown below, when the DAG
runs the Jinja templating is applied for the `arguments` parameter, but not for
the `env_vars` parameter, as we see in the logs from the task no all lines have
the expected values substituted.
```
from airflow.contrib.operators.kubernetes_pod_operator import
KubernetesPodOperator
ds = "{{ ds }}"
ts = "{{ ts }}"
passing = KubernetesPodOperator(
namespace='airflow',
image="python:3.6",
cmds=["python", "-c"],
arguments=[f"import os; print('{my_secret}'); print('{ds}');
print('{ts}'); print(os.environ['TEST_DS']); print(os.environ['TEST_TS']);
exit(0)"],
env_vars={
"TEST_DS": ds,
"TEST_TS": "{{ ts }}"
},
labels={"foo": "bar"},
name="passing-task",
task_id="passing-task",
is_delete_operator_pod=True,
get_logs=True,
dag=dag,
)
```
```
[2021-05-27 19:17:33,424] {pod_launcher.py:136} INFO - this is the value for
this variable
[2021-05-27 19:17:33,424] {pod_launcher.py:136} INFO - 2021-05-27
[2021-05-27 19:17:33,425] {pod_launcher.py:136} INFO -
2021-05-27T19:17:25.205147+00:00
[2021-05-27 19:17:33,425] {pod_launcher.py:136} INFO - {{ ds }}
[2021-05-27 19:17:33,425] {pod_launcher.py:136} INFO - {{ ts }}
```
**What you expected to happen**:
It is documented
[here](https://airflow.apache.org/docs/apache-airflow-providers-cncf-kubernetes/stable/_api/airflow/providers/cncf/kubernetes/operators/kubernetes_pod/index.html#airflow.providers.cncf.kubernetes.operators.kubernetes_pod.KubernetesPodOperator.template_fields)
that both `arguments` and `env_vars` are templated fields.
I expect that Jinja templating is applied as expected to values in both
paramters, being the items in the `arguments` list, and the values of the
`env_vars` dictionary.
**How to reproduce it**:
Create a sample DAG with a task defined as above, and run the DAG.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]