Shawnsuun opened a new pull request, #74382:
URL: https://github.com/apache/airflow/pull/74382

   airflowctl's request retry treats every 5xx response and every transport 
error as retryable, regardless of HTTP method. For writes this is unsafe: if a 
`POST`/`PATCH`/`PUT`/`DELETE` times out or receives a 5xx, the server may 
already have applied it, and resending it can create duplicate Dag runs, pools, 
variables, etc.
   
   This change:
   
   - Retries `GET`, `HEAD` and `OPTIONS` as before on 5xx and transport errors.
   - Retries any method only when the request could not have reached the server 
(`ConnectError`, `ConnectTimeout`, `PoolTimeout`).
   - No longer resends other methods after a 5xx, read/write timeout, 
read/write error or protocol error.
   - Prints a warning on stderr when a write fails in one of these ambiguous 
ways: the request may already have been applied, so check the server state 
before retrying.
   - Documents the behaviour under `AIRFLOW_CLI_API_RETRIES`.
   
   Reproduced against a local mock HTTP server that counts requests 
(`airflowctl pools create --name p1 --slots 1`, retry wait set to 0):
   
   | Server behaviour | Before | After |
   |---|---|---|
   | `POST` answered with `503` | 3 `POST`s received | 1 `POST` received + 
warning |
   | `POST` answered after the 5 s read timeout | 3 `POST`s received | 1 `POST` 
received + warning |
   | `GET` (`pools list`) answered with `503` | 3 `GET`s | 3 `GET`s (unchanged) 
|
   | Server not listening, `POST` | retried | retried (unchanged) |
   
   After, for the 503 case:
   
   ```
   Server response error: Server error '503 Service Unavailable' for url 
'http://127.0.0.1:18080/api/v2/pools'
   The POST request failed, but it may already have been applied on the server. 
Check the server state before retrying.
   ```
   
   Tests run locally:
   
   - `uv run --project airflow-ctl pytest airflow-ctl/tests` — 585 passed
   - `prek run mypy-airflow-ctl --all-files` — passed
   - `prek run --stage pre-commit --files <changed files>` — all passed except 
`generate-airflowctl-help-images`, which could not run locally (my local breeze 
setup is broken). Help output is unchanged: I compared the `-h` output of every 
command between `main` and this branch and it is identical, so no help images 
should change.
   
   Related (different problem, already merged): #72429, #73212.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: GitHub Copilot (Claude Opus 5.5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.
   


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