tazimmerman commented on issue #16389:
URL: https://github.com/apache/airflow/issues/16389#issuecomment-939127691
>
>
> 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. `with
DAG(...) as dag:`)
As of 2.1.4 this also happens without the context manager.
```python
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
`manage_slas` function (in `airflow/dag_processing/processor.py`) will
short-circuit when **no** tasks have a valid SLA, but the rest of the code
assumes that all tasks will have a valid SLA (by _valid_ I mean it's a
`timedelta` and thus comparable).
```python
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:
```python
if task.sla and following_schedule + task.sla < timezone.utcnow():
```
--
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]