cccs-seb opened a new issue, #23901:
URL: https://github.com/apache/airflow/issues/23901

   ### Apache Airflow version
   
   2.2.2
   
   ### What happened
   
   When using `execute_timeout` with PythonVirtualenvOperator, the 
AirflowTaskTimeout exception is raised but it does not fail the task.
   
   ### What you think should happen instead
   
   When the timeout hits, the task should fail like it does for all the other 
operators.
   
   ### How to reproduce
   
   Here is my test DAG
   ```Python
   from datetime import datetime, timedelta
   
   from airflow.models import DAG
   from airflow.operators.python import PythonOperator, PythonVirtualenvOperator
   
   args = {
       'owner': 'test',
       'start_date': datetime(2022, 5, 24, 0, 0)
   }
   
   dag = DAG(
       dag_id='test_python_venv',
       default_args=args,
       schedule_interval=None,
       catchup=False,
       dagrun_timeout=timedelta(minutes=10)
   )
   
   def my_callable():
       import time
       print("Sleeping...")
       time.sleep(1000000)
   
   PythonVirtualenvOperator(
       task_id="python_venv",
       dag=dag,
       python_callable=my_callable,
       execution_timeout=timedelta(minutes=1)
   )
   
   PythonOperator(
       task_id="python_no_venv",
       dag=dag,
       python_callable=my_callable,
       execution_timeout=timedelta(minutes=1)
   )
   ```
   
   The Python operator task will timeout like expected, but not the 
PythonVirtualenvOperator.
   
   While running debug logs, here is the output of the PythonVirtualenvOperator 
task:
   ```
   [2022-05-24, 12:42:56 UTC] {taskinstance.py:1427} INFO - Exporting the 
following env vars:
   AIRFLOW_CTX_DAG_OWNER=test
   AIRFLOW_CTX_DAG_ID=test_python_venv
   AIRFLOW_CTX_TASK_ID=python_venv
   AIRFLOW_CTX_EXECUTION_DATE=2022-05-24T16:41:34.776017+00:00
   AIRFLOW_CTX_DAG_RUN_ID=manual__2022-05-24T16:41:34.776017+00:00
   [2022-05-24, 12:42:56 UTC] {__init__.py:146} DEBUG - Preparing lineage 
inlets and outlets
   [2022-05-24, 12:42:56 UTC] {__init__.py:190} DEBUG - inlets: [], outlets: []
   [2022-05-24, 12:42:56 UTC] {process_utils.py:135} INFO - Executing cmd: 
/usr/bin/python3 -m virtualenv /tmp/venvvwhxg2m8 --system-site-packages
   [2022-05-24, 12:42:56 UTC] {process_utils.py:139} INFO - Output:
   [2022-05-24, 12:42:59 UTC] {process_utils.py:143} INFO - created virtual 
environment CPython3.8.10.final.0-64 in 2710ms
   [2022-05-24, 12:42:59 UTC] {process_utils.py:143} INFO -   creator 
CPython3Posix(dest=/tmp/venvvwhxg2m8, clear=False, global=True)
   [2022-05-24, 12:42:59 UTC] {process_utils.py:143} INFO -   seeder 
FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, 
pkg_resources=latest, via=copy, 
app_data_dir=/home/sm/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
   [2022-05-24, 12:42:59 UTC] {process_utils.py:143} INFO -   activators 
BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
   [2022-05-24, 12:42:59 UTC] {process_utils.py:135} INFO - Executing cmd: 
/tmp/venvvwhxg2m8/bin/python /tmp/venvvwhxg2m8/script.py 
/tmp/venvvwhxg2m8/script.in /tmp/venvvwhxg2m8/script.out 
/tmp/venvvwhxg2m8/string_args.txt
   [2022-05-24, 12:42:59 UTC] {process_utils.py:139} INFO - Output:
   [2022-05-24, 12:43:00 UTC] {process_utils.py:143} INFO - [2022-05-24, 
12:43:00 UTC] {settings.py:210} DEBUG - Setting up DB 
connection pool (PID 158989)
   [2022-05-24, 12:43:00 UTC] {process_utils.py:143} INFO - [2022-05-24, 
12:43:00 UTC] {plugins_manager.py:287} DEBUG - Loading 
plugins
   [2022-05-24, 12:43:00 UTC] {process_utils.py:143} INFO - [2022-05-24, 
12:43:00 UTC] {plugins_manager.py:231} DEBUG - Loading plugins 
from directory: /home/sm/airflow/plugins
   [2022-05-24, 12:43:00 UTC] {process_utils.py:143} INFO - [2022-05-24, 
12:43:00 UTC] {plugins_manager.py:211} DEBUG - Loading plugins 
from entrypoints
   [2022-05-24, 12:43:00 UTC] {process_utils.py:143} INFO - [2022-05-24, 
12:43:00 UTC] {plugins_manager.py:445} DEBUG - Integrate DAG 
plugins
   [2022-05-24, 12:43:01 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:01 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:01 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:06 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:06 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:06 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:11 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:11 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:11 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:16 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:16 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:16 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:21 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:21 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:21 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:26 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:26 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:26 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:31 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:31 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:31 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:36 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:36 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:36 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:41 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:41 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:41 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:46 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:46 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:46 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:51 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:51 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:51 UTC] {base_job.py:227} DEBUG - [heartbeat]
   [2022-05-24, 12:43:56 UTC] {timeout.py:36} ERROR - Process timed out, PID: 
158977
   [2022-05-24, 12:43:56 UTC] {taskinstance.py:720} DEBUG - Refreshing 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]> from DB
   [2022-05-24, 12:43:56 UTC] {taskinstance.py:761} DEBUG - Refreshed 
TaskInstance <TaskInstance: test_python_venv.python_venv 
manual__2022-05-24T16:41:34.776017+00:00 [running]>
   [2022-05-24, 12:43:56 UTC] {base_job.py:227} DEBUG - [heartbeat]
   ```
   
   ### Operating System
   
   NAME="Ubuntu" VERSION="20.04.2 LTS (Focal Fossa)"
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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