hkc-8010 commented on code in PR #66911:
URL: https://github.com/apache/airflow/pull/66911#discussion_r3260589635


##########
task-sdk/src/airflow/sdk/api/client.py:
##########
@@ -870,9 +870,18 @@ def trigger(
         )
 
         try:
-            self.client.post(
-                f"dag-runs/{dag_id}/{run_id}", 
content=body.model_dump_json(exclude_defaults=True)
+            self.client._request_without_retry(
+                "POST", f"dag-runs/{dag_id}/{run_id}", 
content=body.model_dump_json(exclude_defaults=True)

Review Comment:
   Done in e30cdc50d16. `trigger()` now performs a `GET 
dag-runs/{dag_id}/{run_id}` pre-check before the `POST`. If the Dag run already 
exists, `reset_dag_run=True` clears it and the default path returns 
`DAGRUN_ALREADY_EXISTS`. If the detail endpoint is unavailable, the client 
falls back to the existing POST path for compatibility.



##########
task-sdk/src/airflow/sdk/api/client.py:
##########
@@ -870,9 +870,18 @@ def trigger(
         )
 
         try:
-            self.client.post(
-                f"dag-runs/{dag_id}/{run_id}", 
content=body.model_dump_json(exclude_defaults=True)
+            self.client._request_without_retry(
+                "POST", f"dag-runs/{dag_id}/{run_id}", 
content=body.model_dump_json(exclude_defaults=True)
             )
+        except httpx.RequestError:
+            if not reset_dag_run and self._dag_run_exists(dag_id=dag_id, 
run_id=run_id):

Review Comment:
   Done in e30cdc50d16. I implemented the pre-check flow from this comment: 
pre-existing Dag runs clear or return `DAGRUN_ALREADY_EXISTS` without posting, 
and the trigger POST only happens when the pre-check says the run is missing or 
the check is unavailable. Ambiguous read-side POST failures are converted to 
`OKResponse` only when the pre-check saw the run as missing and the follow-up 
GET finds it. `ConnectError` and `PoolTimeout` still propagate.
   
   I also added regression coverage for pre-existing conflict and reset, 
unsupported and failed pre-check fallback, ambiguous 
`ReadError`/`ReadTimeout`/`RemoteProtocolError`, the conservative 
pre-check-unknown path, direct `409` behavior, reset conflict clearing, and 
`ConnectError`/`PoolTimeout` propagation.



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