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


##########
airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -224,7 +226,26 @@ def ti_update_state(
             next_kwargs=ti_patch_payload.trigger_kwargs,
             trigger_timeout=timeout,
         )
+    elif isinstance(ti_patch_payload, TIRescheduleStatePayload):
+        task_instance = session.get(TI, ti_id_str)
+        actual_start_date = timezone.utcnow()
+        # add changes to TaskReschedule table to the session
+        session.add(
+            TaskReschedule(
+                task_instance.task_id,
+                task_instance.dag_id,
+                task_instance.run_id,
+                task_instance.try_number,
+                actual_start_date,
+                task_instance.end_date,

Review Comment:
   Thanks for the point. I agree with you that we need "end_date". I have 
changed the code now to handle it like it is handled for the 
`TITerminalStatePayload` related states.
   
   As for adding query like `query = 
TI.duration_expression_update(ti_patch_payload.end_date, query, session.bind) 
`, we do not need that to calculate the duration because the model itself has 
logic to do that as long as rthe start and end dates are set properly. I have 
adding a unit test that can validate this part as well. 
https://github.com/apache/airflow/blob/main/airflow/models/taskreschedule.py#L95-L98



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