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 2022/04/12 04:09:08 UTC
[GitHub] [airflow] tirkarthi opened a new issue, #22933: Task duration page crashes when there is a failed task entry
tirkarthi opened a new issue, #22933:
URL: https://github.com/apache/airflow/issues/22933
### Apache Airflow version
2.2.5 (latest released)
### What happened
Task duration page crashes when there is a failed task in the list of task instances. This happens since the chart calculates duration and accesses `execution_date` on `TaskFail` instances which don't exist. The query should be modified such that relevant `TaskInstance` execution_date field should be used based on matching run_id between `TaskInstance` and `TaskFail`.
### What you think should happen instead
_No response_
### How to reproduce
1. Create a dag that fails.
2. After an execution visit the task duration page.
```python
import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
with DAG(
"raise_exception_1",
description="DAG that cuases failure",
tags=["example-failure"],
catchup=False,
start_date=datetime.datetime(2022, 3, 28),
default_args={
"depends_on_past": False,
"email": ["airflow@example.com"],
"email_on_failure": False,
"email_on_retry": False,
"retries": 0,
},
) as dag:
t1 = BashOperator(task_id="sleep_5", bash_command="sleep 5 && invalid")
t1 = BashOperator(task_id="sleep_10", bash_command="sleep 10")
```
```python
Python version: 3.10.4
Airflow version: 2.3.0.dev0
Node: laptop
-------------------------------------------------------------------------------
Traceback (most recent call last):
File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/karthikeyan/stuff/python/airflow/airflow/www/auth.py", line 40, in decorated
return func(*args, **kwargs)
File "/home/karthikeyan/stuff/python/airflow/airflow/www/decorators.py", line 80, in wrapper
return f(*args, **kwargs)
File "/home/karthikeyan/stuff/python/airflow/airflow/utils/session.py", line 71, in wrapper
return func(*args, session=session, **kwargs)
File "/home/karthikeyan/stuff/python/airflow/airflow/www/views.py", line 2911, in duration
failed_task_instance.execution_date,
AttributeError: 'TaskFail' object has no attribute 'execution_date'
```
### Operating System
Ubuntu 20.04
### Versions of Apache Airflow Providers
_No response_
### Deployment
Virtualenv installation
### Deployment details
_No response_
### Anything else
_No response_
### Are you willing to submit PR?
- [X] 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: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] tirkarthi commented on issue #22933: Task duration page crashes when there is a failed task entry
Posted by GitBox <gi...@apache.org>.
tirkarthi commented on issue #22933:
URL: https://github.com/apache/airflow/issues/22933#issuecomment-1106006725
Closing since it's fixed in https://github.com/apache/airflow/pull/23008
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] tirkarthi commented on issue #22933: Task duration page crashes when there is a failed task entry
Posted by GitBox <gi...@apache.org>.
tirkarthi commented on issue #22933:
URL: https://github.com/apache/airflow/issues/22933#issuecomment-1095972343
Sample test case, I will submit a PR shortly.
```python
def test_task_fail_duration(app, admin_client, dag_maker, session):
"""Task duration page with a TaskFail entry should render without error."""
with dag_maker() as dag:
op1 = BashOperator(task_id='fail', bash_command='sleep 5 && exit 1')
op2 = BashOperator(task_id='success', bash_command='exit 0')
with pytest.raises(AirflowException):
op1.run()
op2.run()
op1_fails = (
session.query(TaskFail)
.filter(
TaskFail.task_id == 'fail',
TaskFail.dag_id == dag.dag_id,
)
.all()
)
op2_fails = (
session.query(TaskFail)
.filter(
TaskFail.task_id == 'success',
TaskFail.dag_id == dag.dag_id,
)
.all()
)
assert len(op1_fails) == 1
assert len(op2_fails) == 0
with unittest.mock.patch.object(app, 'dag_bag') as mocked_dag_bag:
mocked_dag_bag.get_dag.return_value = dag
resp = admin_client.get(f"dags/{dag.dag_id}/duration", follow_redirects=True)
breakpoint()
assert resp.status_code == 200
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] tirkarthi closed issue #22933: Task duration page crashes when there is a failed task entry
Posted by GitBox <gi...@apache.org>.
tirkarthi closed issue #22933: Task duration page crashes when there is a failed task entry
URL: https://github.com/apache/airflow/issues/22933
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org