-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SLAs for only one task in a DAG #16389
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! |
@jhtimmins any updated? We faced the same issue |
To add some more findings from my personal testing - this seems to only appear when using the context manager style of defining a DAG (e.g. |
As of 2.1.4 this also happens without the context manager. Traceback (most recent call last):
File "/local/airflow/lib/python3.8/site-packages/airflow/dag_processing/processor.py", line 545, in execute_callbacks
elif isinstance(request, SlaCallbackRequest):
File "/local/airflow/lib/python3.8/site-packages/airflow/utils/session.py", line 70, in wrapper
return func(*args, session=session, **kwargs)
File "/local/airflow/lib/python3.8/site-packages/airflow/dag_processing/processor.py", line 413, in manage_slas
if following_schedule + task.sla < timezone.utcnow():
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType' From what I can tell it's because the check at the start of the while dttm < timezone.utcnow():
following_schedule = dag.following_schedule(dttm)
if following_schedule + task.sla < timezone.utcnow():
session.merge(
SlaMiss(task_id=ti.task_id, dag_id=ti.dag_id, execution_date=dttm, timestamp=ts)
)
dttm = dag.following_schedule(dttm) I'm not sure if there are other repercussions but it seems like an easy fix is to change that check line to: if task.sla and following_schedule + task.sla < timezone.utcnow(): |
It appears that commit 2fd3f27 will resolve the issue. |
I have tested using astronomer ap-airflow image |
great. closing the issue then |
Apache Airflow version: 2.1.0
Kubernetes version (if you are using kubernetes) (use
kubectl version
): NAEnvironment:
uname -a
): Linux 5.4.0-1049-aws Why do we need a CeleryExecutor in order to use the UI features? #51~18.04.1-Ubuntu SMP x86_64 x86_64 x86_64 GNU/LinuxWhat happened:
We migrated from 1.10.15 this week, and noticed SLA misses are not being reported in UI and callback isn't triggered. Usually we have some checkpoint task in our largest DAGs and the SLA is defined only for that task, the task also helps us set up cross-DAG dependencies.
What you expected to happen:
SLA misses are registered in UI and trigger the callback.
What do you think went wrong?
I think tasks without SLA should be excluded from the loop here:
airflow/airflow/jobs/scheduler_job.py
Lines 411 to 438 in 304e174
How to reproduce it:
With this DAG you can check that the SLA is not detected.
But to get the error mentioned below, you need to add a callback function.
Anything else we need to know:
This error happens every time for every DAG that has SLA on some tasks, and the same DAG definition worked fine in v1.10.15.
Scheduler's log
We've seen this error in the scheduler for all the DAGs:[2021-06-09 20:30:57,679] {scheduler_job.py:396} INFO - Running SLA Checks for company_dag
[2021-06-09 20:30:57,763] {scheduler_job.py:569} ERROR - Error executing SlaCallbackRequest callback for file: /opt/airflow/tasks/airflow_dags/eu-central-1/company_dag.py
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/airflow/jobs/scheduler_job.py", line 565, in execute_callbacks
self.manage_slas(dagbag.dags.get(request.dag_id))
File "/usr/local/lib/python3.8/dist-packages/airflow/utils/session.py", line 70, in wrapper
return func(*args, session=session, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/airflow/jobs/scheduler_job.py", line 433, in manage_slas
if following_schedule + task.sla < timezone.utcnow():
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType'
The text was updated successfully, but these errors were encountered: