SLA Misses not being recorded
Airflow v1.6.1 For our DAGs which run daily we aren't seeing any SLA misses being recorded when the SLA is missed
I think the issue is here:
for ti in max_tis:
task = dag.get_task(ti.task_id)
dttm = ti.execution_date
if task.sla:
dttm = dag.following_schedule(dttm)
following_schedule = dag.following_schedule(dttm)
while dttm < datetime.now():
if following_schedule + task.sla < datetime.now():
session.merge(models.SlaMiss(
task_id=ti.task_id,
dag_id=ti.dag_id,
execution_date=dttm,
timestamp=ts))
dttm = dag.following_schedule(dttm)
Lets say our DAG runs daily and today is 2016-01-06 (execution_date 2016-01-05T00:00) and that yesterday 2016-01-05 (execution_date 2016-01-04T00:00) ran successfully. This would imply that for today's run, we would have the following walk through:
dttm = 2016-01-05T00:00dttm = 2016-01-06T00:00following_schedule = 2016-01-07T00:00Sofollowing_schedule + task.sla < datetime.now()will always be false (unless the task takes more than the schedule interval (24 hours) and the SLA time to complete. I think we should instead just haveif dttm + task.sla < datetime.now():
+1 :)
I think there's a bug there but I'm not sure that it's what you describe.
The behavior we want is if SLA is 1 hour, we should error for the 2016-01-01 run at 2016-01-02T01:00:00 since the 2016-01-01 run can't start before 2016-01-02.
One problem I see is that following_schedule = dag.following_schedule(dttm) should be in the while loop.
https://github.com/airbnb/airflow/pull/840