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

   When a deferred `KubernetesPodOperator` task polls a pod whose 
`container_statuses` do not include the base container, the task used to fail 
with:
   
   ```
   RuntimeError: coroutine raised StopIteration
   ```
   
   That message names neither the pod nor the container that was expected, so 
there is nothing to act on. It came from `define_container_state` looking up 
the base container with `next()` and no default: the resulting `StopIteration` 
is converted into an opaque `RuntimeError` as soon as it leaves the trigger's 
coroutine.
   
   The trigger now reports what it actually found. A base container the pod 
never declares in its spec ends the task with a `failed` event naming the pod 
and the containers it does declare. A base container that is declared but has 
not reported a status yet is treated as still starting, so the trigger keeps 
polling as before, and the accompanying warning is logged once per trigger 
instance rather than on every poll.
   
   The task-level hang that an endless pod can still cause is out of scope 
here: `_clean` in the operator waits for pod completion without a time limit, 
on `main` as well as on this branch. This PR only stops the trigger from 
polling forever.
   
   No newsfragment: `providers/` changes are picked up from `git log` by the 
provider release manager.
   
   ### Tests
   
   New tests in 
`providers/cncf/kubernetes/tests/unit/cncf/kubernetes/triggers/test_pod.py` 
cover the warn-once behaviour, the three `has_base_container_in_spec` cases, 
and both `run()` paths (undeclared container ends with `failed`, declared 
container without a status keeps waiting). All three fail against the previous 
`define_container_state`, and that run reproduces the original `coroutine 
raised StopIteration`.
   
   Executed with `breeze`:
   
   | Check | Result |
   | --- | --- |
   | `pytest 
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/triggers/test_pod.py` | 47 
passed, 4 skipped |
   | `Providers[cncf.kubernetes]` suite | 1504 passed, 19 skipped |
   | GKE trigger tests | 23 passed |
   | EKS trigger tests | 19 passed |
   | `mypy` on both changed files | no issues |
   | `prek --stage pre-commit` and `--stage manual` | passed |
   
   Not executed: nothing ran against a real cluster.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 5)
   
   Generated-by: Claude Code (Opus 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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