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

   ## Problem
   
   In `GKEJobTrigger.run()`, when `do_xcom_push=True`, the trigger rediscovery 
loop was polling for pods with `p.status.phase == "Succeeded"`:
   ```python
   succeeded_pods = [p for p in current_pods if p.status and p.status.phase == 
"Succeeded"]
   ```
   However, when `do_xcom_push=True`, the Kubernetes pod has an 
`airflow-xcom-sidecar` container attached which continues running until 
`extract_xcom` sends it the termination signal (`SIGINT`). As a result, 
Kubernetes keeps the pod in `Running` phase, and the pod *never* reaches `phase 
== "Succeeded"` prior to XCom extraction.
   
   Because `succeeded_pods` was always empty, the trigger timed out after 10 
polling intervals and fell back to `self.pod_names`. If the Kubernetes Job 
failed on its initial pod and retried, `self.pod_names` only contained the 
original failed pod, causing XCom extraction to attempt reading from the failed 
pod instead of the retried running pod whose base container succeeded.
   
   ## Solution
   
   1. Added `_is_pod_succeeded(pod)` helper in `GKEJobTrigger` that checks 
whether the base container completed successfully using 
`container_is_succeeded(pod, self.base_container_name)` while excluding failed 
pods (`phase == "Failed"`).
   2. Filter rediscovered pods with `self._is_pod_succeeded(p)` so retried pods 
waiting for XCom extraction are correctly detected.
   3. Added unit tests:
      - 
`test_run_do_xcom_push_uses_retry_pod_with_running_phase_and_succeeded_container`
      - `test_is_pod_succeeded` covering various pod and container lifecycle 
states.
   
   closes: #76871


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