You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jayachandrakasarla (via GitHub)" <gi...@apache.org> on 2026/06/12 13:01:24 UTC

[PR] made await_pod_start to run before await_init_containers_completion [airflow]

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

   Closes #68445 
   
   ### Problem
   When KubernetesPodOperator is configured with `init_container_logs=True`, the task hangs indefinitely if the pod never leaves the Pending phase (e.g. due to an invalid node_selector, missing node pool, or resource exhaustion).
   
   With `init_container_logs=False`, `PodLaunchTimeoutException` is raised correctly after `startup_timeout_seconds / schedule_timeout_seconds`. With `init_container_logs=True`, the task never times out and the pod is never cleaned up.
   
   You can reproduce the issue using the following DAG code:
   ```python
   from __future__ import annotations
   
   from pendulum import datetime
   
   from airflow.sdk import dag
   from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
   from kubernetes.client import models as k8s
   
   
   @dag(
       dag_id="kpo_pending_init_container_logs",
       start_date=datetime(2025, 1, 1),
       schedule=None,
       catchup=False,
   )
   def kpo_pending_init_container_logs():
       KubernetesPodOperator(
           task_id="kpo_pending_with_init_logs",
           name="kpo-pending-with-init-logs",
           namespace="default",
           image="busybox:1.36",
           cmds=["sh", "-c"],
           arguments=["echo main container should never start; sleep 30"],
   
           deferrable=False,
   
           # setting the below value to True makes the task hang for long time
           init_container_logs=True,
           init_containers=[
               k8s.V1Container(
                   name="init-hello",
                   image="busybox:1.36",
                   command=["sh", "-c"],
                   args=["echo init container should never start; sleep 30"],
               )
           ],
   
           # schedule the pod on a non-existing node to make sure the pod stays in the pending state
           node_selector={
               "airflow-repro-node": "does-not-exist",
           },
   
           # Expected behavior: should fail after timeout.
           # Bug: hangs forever when init_container_logs=True.
           startup_timeout_seconds=30,
           schedule_timeout_seconds=30,
   
           get_logs=True,
           is_delete_operator_pod=False,
           in_cluster=False,
           config_file="/files/kube/config"
       )
   
   
   kpo_pending_init_container_logs()
   ```
   
   ### Fix
   Made `self.await_pod_start()` to run before `self.await_init_containers_completion()` to ensure the pod has fully started before attempting to stream init container logs, preventing KPO from hanging when init container log streaming was triggered against a pod still in PENDING state.
   
   Was generative AI tooling used to co-author this PR?
   
   [X] Yes 
   
   Used Claude Sonnet to understand the codebase and assist with implementing the changes.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix KPO hanging indefinitely when init_container_logs=True and pod stays in Pending [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #68450:
URL: https://github.com/apache/airflow/pull/68450#issuecomment-4694493186

   Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional 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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix KPO hanging indefinitely when init_container_logs=True and pod stays in Pending [airflow]

Posted by "jayachandrakasarla (via GitHub)" <gi...@apache.org>.
jayachandrakasarla commented on PR #68450:
URL: https://github.com/apache/airflow/pull/68450#issuecomment-4691772173

   One of [tests is failing](https://github.com/apache/airflow/actions/runs/27414765280/job/81029797077) and I don't think it's related to my changes.
   
   I think the obvious fix for it is by allowing `None` or default to an empty list instead of `None` in the below line in `pod_manager.py`:
   
   `pod_conditions: list[V1PodCondition] = remote_pod.status.conditions if remote_pod.status else None`
   
   Let me know if you want me to make these changes.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix KPO hanging indefinitely when init_container_logs=True and pod stays in Pending [airflow]

Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl merged PR #68450:
URL: https://github.com/apache/airflow/pull/68450


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org