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/02 21:19:00 UTC

[GitHub] [airflow] ramsesrm opened a new issue #13445: BashOperator "env" should extend os envvars and not entirely replacing them

ramsesrm opened a new issue #13445:
URL: https://github.com/apache/airflow/issues/13445


   **Description**
   
   Current (1.10.14) behavior of BashOperator's is entirely replacing the os env by the envvars present in the "env" dict, if exists.
   
   Perhaps it should extend the os envvars with the ones in the env dict, instead.
   
   **Use case / motivation**
   
   I'm using a BashOperator + custom env dict on an Airflow stable helm installation, and i had to add an additional env dict entry like this to make it work:
   
   ``
           env={
               "PATH": "$PATH:/bin",
   ``
   
   as using the "env" entry the original os PATH variable is ignored, and Airflow can't even find "bash" command.
   


----------------------------------------------------------------
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 #13445: BashOperator "env" should extend os envvars and not entirely replacing them

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


   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] ramsesrm commented on issue #13445: BashOperator "env" should extend os envvars and not entirely replacing them

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


   Hi @mik-laj, thanks for the clarification, i didn't consider the value of isolating the script from the os envs. I'm closing this one :)


----------------------------------------------------------------
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] ramsesrm closed issue #13445: BashOperator "env" should extend os envvars and not entirely replacing them

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


   


----------------------------------------------------------------
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 #13445: BashOperator "env" should extend os envvars and not entirely replacing them

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


   Copying all the environmental ones doesn't sound good to me. There are cases when Airflow has certain environmental variables, and the script should not have these variables, especially since environment variables very often contain secrets.
   
   You can easily add this behavior in your DAG code so I don't see any reason to make suggested change.
   ````bash
       task = BashOperator(
           task_id='runme',
           bash_command='./my-script.sh ',
           dag=dag,
           env={
               'CUSTOM_ENV': 'CUSTOM_VALUE',
               **os.environ
           }
       )
   ````
   


----------------------------------------------------------------
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