kaxil commented on a change in pull request #14064:
URL: https://github.com/apache/airflow/pull/14064#discussion_r570144364



##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -419,7 +419,7 @@ 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):
+            if not task.sla:

Review comment:
       The problem with this approach is it will fail the entire 
DagfileProcessorProcess that is running SlaCallback.
   
   So imagine if there are 5 tasks, only 1 of them has `task.sla=3` and others 
have `task.sla=timedelta(seconds=3)`, then with the current change it will 
raise type error and will not run or check sla for Tasks that have correct 
task.sla set.
   
   

##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -419,7 +419,7 @@ 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):
+            if not task.sla:

Review comment:
       I think a better fix would be something like:
   
   ```python
   if task.sla and not isinstance(task.sla, timedelta):
        raise("Expected timedelta object, got %s instead: %s", type(task.sla), 
task.sla)
   ```
   
   This would help users understand what's the problem 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to