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

   ## Summary
   
   `init_container_logs` on `KubernetesPodOperator` only worked when 
`deferrable=False`. The sync execution path 
(`await_init_containers_completion`) fetched and streamed init container logs, 
but `KubernetesPodTrigger` (used when `deferrable=True`) had no awareness of 
init containers at all — the parameter was silently accepted and ignored, and 
no init container logs ever surfaced for deferred tasks.
   
   This PR:
   - Threads `init_container_logs` from the operator through 
`invoke_defer_method` into `KubernetesPodTrigger`, and serializes it so it 
survives triggerer restarts.
   - Adds `fetch_requested_init_container_logs` / `_await_init_container_start` 
/ `_stream_init_container_logs_until_completion` to `AsyncPodManager`, 
streaming each requested init container's logs in `spec.initContainers` order 
once the pod leaves `Pending`, mirroring the sync `PodManager`'s behaviour.
   - Extracts the shared container-name reconciliation logic 
(`_reconcile_requested_log_containers`) into a module-level 
`reconcile_requested_log_containers` function reused by both `PodManager` and 
`AsyncPodManager`.
   - Fixes a related bug found while implementing this: completion detection 
uses `get_container_status()` rather than the existing 
`container_is_terminated()` helper, since the latter only inspects 
`pod.status.container_statuses` and never matches init containers (which live 
in `init_container_statuses`), which would have caused the new polling loop to 
hang.
   
   closes: #72504
   
   ## Test plan
   
   - [x] Added unit tests for 
`AsyncPodManager.fetch_requested_init_container_logs` and its helpers, 
including a regression test guarding the `container_is_terminated` pitfall 
above.
   - [x] Added a `KubernetesPodTrigger._wait_for_pod_start` test confirming 
init container logs are (and aren't, when unset) fetched.
   - [x] Added an operator test confirming `init_container_logs` reaches the 
trigger via `invoke_defer_method`.
   - [x] `uv run ruff format` / `ruff check --fix` clean on all changed files.
   - [x] `mypy` clean on all changed source files.
   - [x] Full `pytest` run of the three affected test files: all pass except 
two pre-existing, unrelated flaky tests (`since_seconds` timezone-sensitive 
assertions that also fail on `main` without this change).
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Sonnet 5)
   
   Generated-by: Claude Code (Sonnet 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


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