shohamy7 commented on issue #36136:
URL: https://github.com/apache/airflow/issues/36136#issuecomment-1902244091

   Hi @buu-nguyen 
   I've tried to reproduce your issue but I didn't manage to get the same 
results you are experiencing.
   I've used the following DAG:
   
   ```
   from datetime import datetime, timedelta
   from airflow import DAG
   from kubernetes import client as k8s
   
   from airflow.operators.python import PythonOperator
   
   # Define default_args dictionary to specify the default parameters of the DAG
   default_args = {
       'owner': 'airflow',
       'depends_on_past': False,
       'start_date': datetime(2024, 1, 1),
       'email_on_failure': False,
       'email_on_retry': False,
       'retries': 2,
       'retry_delay': timedelta(minutes=5),
   }
   
   
   def print_greetings(ti, **kwargs):
       import os
       greetings = os.getenv('GREETING', "No greeting")
       print(f"kwargs: {kwargs}")
       print(f"ti: {ti}")
       print(f"try number: {ti.try_number}")
       if ti.try_number > 1:
           print(f"Greeting: {greetings}")
       else:
           raise Exception("Error!")
   
   
   # Define the DAG object with the specified parameters
   dag = DAG(
       dag_id='example_k8s_executor_dag',
       default_args=default_args,
       schedule_interval=None,  # This DAG is triggered manually
   )
   
   # Define the BashOperator task that prints the greeting to stdout
   print_greeting_task = PythonOperator(
       task_id='print_greeting',
       python_callable=print_greetings,
       executor_config={
           "pod_override": k8s.V1Pod(
               spec=k8s.V1PodSpec(
                   containers=[
                       k8s.V1Container(
                           name="base",
                           env=[
                               k8s.V1EnvVar(
                                   name="GREETING",
                                   value="Hello World!"
                               ),
                           ],
                       ),
                   ]
               )
           )
       },
       dag=dag,
   )
   ```
   
   And after the first try (which failed), I managed to get the expected 
`executor_config` (with the custom environment variable I set) via the Airflow 
REST API (I've used the swagger UI).
   I've tested the `/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances` & 
`/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}`
   Can you please provide more insights about your issue? (your DAG, which 
endpoint you used, etc.)
   


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to