shahar1 opened a new pull request, #77412: URL: https://github.com/apache/airflow/pull/77412
<!-- HUMAN SUMMARY - AGENTS DO NOT MODIFY --> <!-- END OF HUMAN SUMMARY --> <details><summary>AI Summary</summary> The EKS executor gets a new token and sends the request again when the cluster rejects the token with a `401`. With version 37 of the `kubernetes` client that does not work, and #77374 and #77168 are about to allow that version. **Cause.** `_EksApiClient` overrides `ApiClient.call_api`, catches the `401`, expires the token and calls `call_api` again. - Client 36 builds the `Authorization` header inside `call_api` and raises the `401` from it, so the override works. - Client 37 builds the header before `call_api` (in `param_serialize`), and `call_api` returns the response. The `401` is raised later, in `response_deserialize`. So the override does not see the rejection, and a retry would send the rejected token again. **Fix.** `call_api` now also treats a returned `RESTResponse` with status `401` as a rejection. Before the retry it reads that response, so its connection goes back to the pool, and on client 37 it puts the new token in the header. Behaviour with client 36 does not change. The asynchronous client is not changed: it uses `kubernetes_asyncio`, which has no 37 release. **Tests.** The existing tests mocked the transport in the client 36 shape. They now return what the real transport of each client returns, and the waits in the concurrency test have a timeout, so a regression fails and does not hang. That hang is what timed out the `Compat 3.4.0` job on #77374. **How it was checked** - `providers/amazon/tests/unit/amazon/aws/executors/eks`: 49 passed with client 36.0.3 and 49 passed with client 37.0.2. With the fix reverted, 4 of them fail on 37.0.2 within 14 seconds. - A real API server (kind, Kubernetes v1.37.0) with a rejected bearer token, through `_EksApiClient`, on both clients: a list, a list with `_preload_content=False` and a pod creation succeed after one retry; a second rejection ends in `401`; a `403` is not retried. Without the fix, client 37 does not retry. - `prek` pre-commit and manual stages, including provider mypy. Not checked: a real EKS cluster. The calls with `async_req=True` and the `kubernetes.stream` calls do not go through this retry on client 37; the executor uses neither. </details> --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Fable 5.2) Generated-by: Claude Code (Fable 5.2) 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]
