You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/01/07 00:59:41 UTC

[GitHub] [airflow] mfjackson opened a new issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

mfjackson opened a new issue #13522:
URL: https://github.com/apache/airflow/issues/13522


   I'm encountering an issue that I believe is similar to #13348, but am opening a new issue to expand on what is happening in more detail.
   
   **Apache Airflow version**: 2.0.0
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl version`): 1.19.4
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**: GCP, using GKE
   
   
   **What happened**:
   
   My DAG in Airflow 1.10.13 was using a couple of built-in variables and Jinja templating to pass information between `KubernetesPodOperator` tasks (e.g. file paths, execution dates); it looked similar to this:
   
   ```python
   from airflow import DAG
   from airflow.contrib.operators.kubernetes_pod_operator import KubernetesPodOperator
   
   default_args = {'owner': 'airflow'}
   
   example_workflow = DAG('my_dag',
                          default_args=default_args,
                          default_view='graph',
                          schedule_interval='@daily')
   
   with example_workflow:
       example_k8s_task = KubernetesPodOperator(namespace='my_namespace',
                                                image="ubuntu:latest",
                                                name="pod1",
                                                task_id='my_task_id',
                                                env_vars={'TASK_ID': '{{ task.task_id }}'},
                                                cmds=["echo $TASK_ID"]
                                                )
   
       example_k8s_task
   ```
   
   which successfully echoed `'my_task_id'` in the logs when the DAG was triggered and ran successfully.
   
   With the changes to the `KubernetesPodOperator` in Airflow 2.0, I followed the guidelines [here](https://airflow.apache.org/docs/apache-airflow/stable/upgrading-to-2.html#changed-parameters-for-the-kubernetespodoperator) and refactored the above code to look like this:
   
   ```python
   from airflow import DAG
   from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator
   from kubernetes.client import models as k8s
   
   default_args = {'owner': 'airflow'}
   
   my_env_vars = [
       k8s.V1EnvVar(
           name='TASK_ID',
           value='{{ task.task_id }}'
       )]
   
   example_workflow = DAG(dag_id='my_dag',
                          default_args=default_args,
                          default_view='graph',
                          schedule_interval='@daily')
   
   with example_workflow:
       example_k8s_task = KubernetesPodOperator(namespace='my_namespace',
                                                image="ubuntu:latest",
                                                name="pod1",
                                                task_id='my_task_id',
                                                env_vars=my_env_vars,
                                                cmds=["echo $TASK_ID"]
                                                )
   
       example_k8s_task
   ```
   
   However, this echoed `'{{ task.task_id }}'` in the logs, meaning the templated variable did not render properly.
   
   **What I expected to happen**:
   
   I expected to have the templated variable rendered properly and return the variable value, e.g. `'my_task_id'`.
   
   **What I think actually happened**:
   
   While `KubernetesPodOperator` `env_var` parameter is marked as "(templated)" in the [source code](https://github.com/apache/airflow/blob/9c75ea3c14b71d2f96d997aeef68c764c7d2984c/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py#L83), when a string is passed in the `value` parameter of `kubernetes.client` `V1EnvVar` object ([source code](https://github.com/kubernetes-client/python/blob/b79ad6837b2f5326c7dad488a64eed7c3987e856/kubernetes/client/models/v1_env_var.py)), it does not render the template, but rather treats it as a literal string.
   
   **How to reproduce it**:
   
   Set up Airflow on minikube or use your cloud provider's Airflow instance (so easy to set up, I know /s) and run the second Python code snippet above (using Airflow 2.0).
   
   Thanks!


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] dimberman commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
dimberman commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-773532164


   Hi @shihabcsedu09
   
   I've created and linked a PR. Because the KPO lives in a provider once this is merged we can release and you can upgrade for this fix without needing to upgrade your airflow version (just pull the newest provider :) )


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] boring-cyborg[bot] commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-755816129


   Thanks for opening your first issue here! Be sure to follow the issue template!
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] andreychernih commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
andreychernih commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-770311126


   Having a similar issue with the only different in my case is that I pass the `env_vars` directly to `KubernetesPodOperator`:
   
   ```
   download_task = KubernetesPodOperator(
      ...,
      env_vars = {
        'START_DATE': '{{ execution_date.strftime("%Y-%m-%d") }}',
      }
   )
   ```
   
   It is passing the actual `{{ execution_date.strftime("%Y-%m-%d") }}` instead of rendering the template. I am using the official apache/airflow:2.0.0-python3.8 Docker image..


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] SamWheating commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
SamWheating commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-756918974


   I have had the same issue while templating env vars. I tried defining it as both:
   
   `env_vars=["{{ k8s.V1EnvVar(name='DATESTAMP', value=ds) }}"]`
   in which case I got an importError as jinja couldn't find `k8s`
   
   as well as:
   `env_vars=[k8s.V1EnvVar(name='DATESTAMP', value='{{ ds }}')]`
   in which case the rendered value was `{{ ds }}` rather than `2021-01-08`
   
   Is there a suggested workaround for this at the moment? This will prevent us from upgrading to Airflow 2 as we rely on providing environment variables through `dag_run.conf`


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] SamWheating removed a comment on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
SamWheating removed a comment on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-756918974


   I have had the same issue while templating env vars. I tried defining it as both:
   
   `env_vars=["{{ k8s.V1EnvVar(name='DATESTAMP', value=ds) }}"]`
   in which case I got an importError as jinja couldn't find `k8s`
   
   as well as:
   `env_vars=[k8s.V1EnvVar(name='DATESTAMP', value='{{ ds }}')]`
   in which case the rendered value was `{{ ds }}` rather than `2021-01-08`
   
   Is there a suggested workaround for this at the moment? This will prevent us from upgrading to Airflow 2 as we rely on providing environment variables through `dag_run.conf`. 
   
   edit: found the workaround in #13348


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] mik-laj commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
mik-laj commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-756130803


   @dimberman looks like we need to verify our assumptions. In the case of Google operators, we always accept two types - one dictionary, the other is a class.
   https://github.com/apache/airflow/blob/ef2123c671b985953707b056ef30b724f7f97d28/airflow/providers/google/cloud/operators/datacatalog.py#L60
   This is how most users pass the dictionary, but can look at the class definitions if they want to read the documentation.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] shihabcsedu09 commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
shihabcsedu09 commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-773154696






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] kaxil commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
kaxil commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-815304796


   @dimberman You should be able to check it here: https://pypi.org/project/apache-airflow-backport-providers-cncf-kubernetes/#release-202133
   
   https://github.com/apache/airflow/commits/backport-providers-2021.3.3/airflow/providers/cncf/kubernetes
   
   That shows that both https://github.com/apache/airflow/commit/d4c4db8a1833d07b1c03e4c062acea49c79bf5d6#diff-b844df9db37ed0d5a4a081fa659ad506c5f07cc0764b254fbdb9aa24149b059d and https://github.com/apache/airflow/commit/649335c043a9312ef272fa77f2bb830d52cde056#diff-b844df9db37ed0d5a4a081fa659ad506c5f07cc0764b254fbdb9aa24149b059d were included


-- 
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:
users@infra.apache.org



[GitHub] [airflow] kaxil commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
kaxil commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-773624222


   Yup, this is a part of providers and will be released separately from Airflow core


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] andreychernih commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
andreychernih commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-770313579


   It looks like the workaround from https://github.com/apache/airflow/issues/13348 works:
   
   ```
   if not hasattr(k8s.V1EnvVar, 'template_fields'):
       k8s.V1EnvVar.template_fields = ('value',)
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] phlope commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
phlope commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-775877358


   @dimberman @kaxil 
   
   We're running on 1.10.14 currently and hitting the same issue, using the cncf backport provider:
   https://pypi.org/project/apache-airflow-backport-providers-cncf-kubernetes/
   
   Does this also need updating to include the same fix?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] grillorafael commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
grillorafael commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-765397247


   I'm having the same issue trying to update to airflow 2.0.0


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] dimberman commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
dimberman commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-773532164


   Hi @shihabcsedu09
   
   I've created and linked a PR. Because the KPO lives in a provider once this is merged we can release and you can upgrade for this fix without needing to upgrade your airflow version (just pull the newest provider :) )


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] samudurand commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
samudurand commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-814628401


   @dimberman I have just upgraded to the latest backport provider version (2021.3.3 for 1.10.14), but this doesn't seem to include a fix for that issue, is there another release with a fix planned ? 


-- 
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:
users@infra.apache.org



[GitHub] [airflow] dimberman commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
dimberman commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-815125926


   @kaxil did we ever merge this into the cncf backport provider?


-- 
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:
users@infra.apache.org



[GitHub] [airflow] shihabcsedu09 commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
shihabcsedu09 commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-773154696


   @kaxil Looks like it has been removed from the Airflow 2.0.1 milestone. In which release we are expecting this to be fixed? 
   
   Thanks


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] SamWheating removed a comment on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
SamWheating removed a comment on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-756918974


   I have had the same issue while templating env vars. I tried defining it as both:
   
   `env_vars=["{{ k8s.V1EnvVar(name='DATESTAMP', value=ds) }}"]`
   in which case I got an importError as jinja couldn't find `k8s`
   
   as well as:
   `env_vars=[k8s.V1EnvVar(name='DATESTAMP', value='{{ ds }}')]`
   in which case the rendered value was `{{ ds }}` rather than `2021-01-08`
   
   Is there a suggested workaround for this at the moment? This will prevent us from upgrading to Airflow 2 as we rely on providing environment variables through `dag_run.conf`. 
   
   edit: found the workaround in #13348


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] andreychernih edited a comment on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
andreychernih edited a comment on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-770311126


   Having a similar issue with the only difference in my case is that I pass the `env_vars` directly to `KubernetesPodOperator`:
   
   ```
   download_task = KubernetesPodOperator(
      ...,
      env_vars = {
        'START_DATE': '{{ execution_date.strftime("%Y-%m-%d") }}',
      }
   )
   ```
   
   It is passing the actual `{{ execution_date.strftime("%Y-%m-%d") }}` instead of rendering the template. I am using the official apache/airflow:2.0.0-python3.8 Docker image..


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] dimberman commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
dimberman commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-776060570


   @phlope yes when we release the next backport provider it will also have this fix.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] bmfisher commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
bmfisher commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-768590545


   Also experiencing the same issue while trying to upgrade to 2.0.0


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] kaxil edited a comment on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
kaxil edited a comment on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-815304796


   @dimberman You should be able to check it here: https://pypi.org/project/apache-airflow-backport-providers-cncf-kubernetes/#release-202133
   
   https://github.com/apache/airflow/commits/backport-providers-2021.3.3/airflow/providers/cncf/kubernetes
   
   That shows that both https://github.com/apache/airflow/commit/d4c4db8a1833d07b1c03e4c062acea49c79bf5d6#diff-b844df9db37ed0d5a4a081fa659ad506c5f07cc0764b254fbdb9aa24149b059d and https://github.com/apache/airflow/commit/649335c043a9312ef272fa77f2bb830d52cde056#diff-b844df9db37ed0d5a4a081fa659ad506c5f07cc0764b254fbdb9aa24149b059d were included
   
   @dimberman Can you test it and see if it needs some other fix


-- 
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:
users@infra.apache.org



[GitHub] [airflow] shihabcsedu09 commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
shihabcsedu09 commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-773778400


   @dimberman @kaxil Excellent. Thanks. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] SamWheating commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
SamWheating commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-756918974


   I have had the same issue while templating env vars. I tried defining it as both:
   
   `env_vars=["{{ k8s.V1EnvVar(name='DATESTAMP', value=ds) }}"]`
   in which case I got an importError as jinja couldn't find `k8s`
   
   as well as:
   `env_vars=[k8s.V1EnvVar(name='DATESTAMP', value='{{ ds }}')]`
   in which case the rendered value was `{{ ds }}` rather than `2021-01-08`
   
   Is there a suggested workaround for this at the moment? This will prevent us from upgrading to Airflow 2 as we rely on providing environment variables through `dag_run.conf`


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] SamWheating edited a comment on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
SamWheating edited a comment on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-756918974


   I have had the same issue while templating env vars. I tried defining it as both:
   
   `env_vars=["{{ k8s.V1EnvVar(name='DATESTAMP', value=ds) }}"]`
   in which case I got an importError as jinja couldn't find `k8s`
   
   as well as:
   `env_vars=[k8s.V1EnvVar(name='DATESTAMP', value='{{ ds }}')]`
   in which case the rendered value was `{{ ds }}` rather than `2021-01-08`
   
   Is there a suggested workaround for this at the moment? This will prevent us from upgrading to Airflow 2 as we rely on providing environment variables through `dag_run.conf`. 
   
   edit: found the workaround in #13348


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] kaxil commented on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
kaxil commented on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-773624222


   Yup, this is a part of providers and will be released separately from Airflow core


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] SamWheating edited a comment on issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
SamWheating edited a comment on issue #13522:
URL: https://github.com/apache/airflow/issues/13522#issuecomment-756918974


   I have had the same issue while templating env vars. I tried defining it as both:
   
   `env_vars=["{{ k8s.V1EnvVar(name='DATESTAMP', value=ds) }}"]`
   in which case I got an importError as jinja couldn't find `k8s`
   
   as well as:
   `env_vars=[k8s.V1EnvVar(name='DATESTAMP', value='{{ ds }}')]`
   in which case the rendered value was `{{ ds }}` rather than `2021-01-08`
   
   Is there a suggested workaround for this at the moment? This will prevent us from upgrading to Airflow 2 as we rely on providing environment variables through `dag_run.conf`. 
   
   edit: found the workaround in #13348


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] dimberman closed issue #13522: Templated Variables being treated as String by KubernetesPodOperator in Airflow 2.0

Posted by GitBox <gi...@apache.org>.
dimberman closed issue #13522:
URL: https://github.com/apache/airflow/issues/13522


   


----------------------------------------------------------------
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:
users@infra.apache.org