kaxil commented on code in PR #45106:
URL: https://github.com/apache/airflow/pull/45106#discussion_r1898680204


##########
airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -359,3 +369,15 @@ def ti_put_rtif(
     _update_rtif(task_instance, put_rtif_payload, session)
 
     return {"message": "Rendered task instance fields successfully set"}
+
+
+def _is_eligible_to_retry(state: str, try_number: int, max_tries: int) -> bool:
+    """Is task instance is eligible for retry."""
+    if state == State.RESTARTING:
+        # If a task is cleared when running, it goes into RESTARTING state and 
is always
+        # eligible for retry
+        return True
+
+    # max_tries is initialised with the retries defined at task level, we do 
not need to explicitly ask for
+    # retries from the task SDK now, we can handle using max_tries
+    return max_tries != 0 and try_number <= max_tries

Review Comment:
   And a test with `try_number` > `max_tries`



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

Reply via email to