Skip to content

Commit

Permalink
Skip SLA check only if SLA is None (apache#14064)
Browse files Browse the repository at this point in the history
Users have to provide SLA as timedelta. If not provided it should
be a default None value.

This change will result in run time errors if other type than
timedelta is passed as SLA. With this change spotting apache#14056
would be easier.
  • Loading branch information
turbaszek authored Feb 7, 2021
1 parent 0c1ad94 commit 41bf974
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions airflow/jobs/scheduler_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,11 @@ def manage_slas(self, dag: DAG, session: Session = None) -> None:
ts = timezone.utcnow()
for ti in max_tis:
task = dag.get_task(ti.task_id)
if not isinstance(task.sla, timedelta):
continue
if task.sla and not isinstance(task.sla, timedelta):
raise TypeError(
f"SLA is expected to be timedelta object, got "
f"{type(task.sla)} in {task.dag_id}:{task.task_id}"
)

dttm = dag.following_schedule(ti.execution_date)
while dttm < timezone.utcnow():
Expand Down

0 comments on commit 41bf974

Please sign in to comment.