amoghrajesh commented on code in PR #73889:
URL: https://github.com/apache/airflow/pull/73889#discussion_r4248282618


##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -447,6 +447,10 @@ def clear_task_instances(
                 ti.max_tries = max(ti.max_tries, previous_try_number)
             ti.state = None
             ti.external_executor_id = None
+            # retry_delay_override is the functional one: 
next_retry_datetime() prefers it over
+            # the task's own retry_delay, so a stale value would retime the 
next retry.
+            ti.retry_reason = None

Review Comment:
   Updated all three, now saying cleared on clear and when the next attempt is 
scheduled or deferred. Regenerated the spec, UI client and airflowctl models; 
no copy of the old sentence left.



##########
airflow-core/tests/unit/models/test_taskinstance.py:
##########
@@ -4342,6 +4342,25 @@ def 
test_clear_task_instances_resets_context_carrier(dag_maker, session):
     assert dag_run.context_carrier["traceparent"] != original_dr_traceparent
 
 
[email protected]_test
+def test_clear_task_instances_clears_retry_policy_columns(dag_maker, session):
+    """Neither column may survive the clear."""
+    with dag_maker("test_clear_retry_policy_columns"):
+        EmptyOperator(task_id="t1")
+    dag_run = dag_maker.create_dagrun()
+    ti = dag_run.get_task_instance("t1", session=session)
+    ti.state = TaskInstanceState.FAILED
+    ti.retry_reason = "auth error, do not retry"
+    ti.retry_delay_override = 300.0
+    session.flush()
+
+    clear_task_instances([ti], session)
+    session.flush()
+
+    assert ti.retry_reason is None

Review Comment:
   Added a TaskInstanceHistory check that the cleared try keeps both values. 
Confirmed it fails if the reset moves above prepare_db_for_next_try.
   
   



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