Fix KubernetesPodOperator XCom sidecar hang on Alpine - #58931
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
|
I think this script should generally follow the original script with |
potiuk
left a comment
There was a problem hiding this comment.
Please make the alpine approach conditional - not default
d7016d4 to
8c4b5f5
Compare
Nataneljpwd
left a comment
There was a problem hiding this comment.
Looks good, maybe it is a good idea to convert to exception and try catch instead of changing the method definition, as I feel it is more idiomatic, other than that, great find!
|
Maybe it is also worth to add a test so that we can avoid regression in the future |
|
I agree, I'll convert to it into exception and try/catch. |
|
Still failing |
Fixed |
|
One general question: You say "some Alpine versions" - do you know which? Is it then in general rather advisable to prevent usage of these versions? |
On Alpine versions older than 3.14 the "-u" flag in "pgrep" doesn't exist, and it happened because the xcom sidecar image was specifically set to this version. |
|
I am not sure. Have you considered the option to update the Alpine image? Why should we support an older version if there is a new out? This is already ~3 years old... |
Upgrading the image does solve the issue in this case, but since there isn’t a compatibility matrix for the XCom sidecar and users can specify any version, it might be better to implement a generic fallback. Having the user manually configure the kill command could add unnecessary friction to the user experience. |
The [extract_xcom_kill] method previously used to identify and kill the sidecar process. However, the implementation in some Alpine/BusyBox versions does not support the flag, causing the command to fail and the sidecar to hang indefinitely. This commit replaces the command with a portable shell loop that iterates over to identify processes owned by the current user. This ensures compatibility with all Alpine versions and removes the dependency on .
This reverts commit 8c4b5f5.
a55d78f to
bdba85a
Compare
For me this is not fully convincing. If you assume somebody is updating providers to have this convenience why not expecting to also update Alpine image? Is there a reason to use the 3y old image? |
|
Maybe a good idea might be to add a compatibility matrix in the docs? |
I am fine with it - as long as it is fallback |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
|
Hi maintainer, this PR was merged without a milestone set.
|
…8931) * Fix KubernetesPodOperator XCom sidecar hang on Alpine The [extract_xcom_kill] method previously used to identify and kill the sidecar process. However, the implementation in some Alpine/BusyBox versions does not support the flag, causing the command to fail and the sidecar to hang indefinitely. This commit replaces the command with a portable shell loop that iterates over to identify processes owned by the current user. This ensures compatibility with all Alpine versions and removes the dependency on . * changed alpine fallback command * added conditional fallback xcom kill command when the primary one fails * Revert "changed alpine fallback command" This reverts commit 8c4b5f5. * Convert the xcom kill command conditioning to exception and try/catch * Fixed command string format (cherry picked from commit ed78d6c) Co-authored-by: Yahely Ushpiz <102915448+YahelyUshpiz@users.noreply.github.com>
Backport successfully created: v3-1-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…ache#58931) * Fix KubernetesPodOperator XCom sidecar hang on Alpine The [extract_xcom_kill] method previously used to identify and kill the sidecar process. However, the implementation in some Alpine/BusyBox versions does not support the flag, causing the command to fail and the sidecar to hang indefinitely. This commit replaces the command with a portable shell loop that iterates over to identify processes owned by the current user. This ensures compatibility with all Alpine versions and removes the dependency on . * changed alpine fallback command * added conditional fallback xcom kill command when the primary one fails * Revert "changed alpine fallback command" This reverts commit 8c4b5f5. * Convert the xcom kill command conditioning to exception and try/catch * Fixed command string format (cherry picked from commit ed78d6c) Co-authored-by: Yahely Ushpiz <102915448+YahelyUshpiz@users.noreply.github.com>
|
This is provider only. |
* Fix KubernetesPodOperator XCom sidecar hang on Alpine The [extract_xcom_kill] method previously used to identify and kill the sidecar process. However, the implementation in some Alpine/BusyBox versions does not support the flag, causing the command to fail and the sidecar to hang indefinitely. This commit replaces the command with a portable shell loop that iterates over to identify processes owned by the current user. This ensures compatibility with all Alpine versions and removes the dependency on . * changed alpine fallback command * added conditional fallback xcom kill command when the primary one fails * Revert "changed alpine fallback command" This reverts commit 8c4b5f5. * Convert the xcom kill command conditioning to exception and try/catch * Fixed command string format
* Fix KubernetesPodOperator XCom sidecar hang on Alpine The [extract_xcom_kill] method previously used to identify and kill the sidecar process. However, the implementation in some Alpine/BusyBox versions does not support the flag, causing the command to fail and the sidecar to hang indefinitely. This commit replaces the command with a portable shell loop that iterates over to identify processes owned by the current user. This ensures compatibility with all Alpine versions and removes the dependency on . * changed alpine fallback command * added conditional fallback xcom kill command when the primary one fails * Revert "changed alpine fallback command" This reverts commit 8c4b5f5. * Convert the xcom kill command conditioning to exception and try/catch * Fixed command string format
* Fix KubernetesPodOperator XCom sidecar hang on Alpine The [extract_xcom_kill] method previously used to identify and kill the sidecar process. However, the implementation in some Alpine/BusyBox versions does not support the flag, causing the command to fail and the sidecar to hang indefinitely. This commit replaces the command with a portable shell loop that iterates over to identify processes owned by the current user. This ensures compatibility with all Alpine versions and removes the dependency on . * changed alpine fallback command * added conditional fallback xcom kill command when the primary one fails * Revert "changed alpine fallback command" This reverts commit 8c4b5f5. * Convert the xcom kill command conditioning to exception and try/catch * Fixed command string format
The [extract_xcom_kill] method previously used to identify and kill the sidecar process. However, the implementation in some Alpine/BusyBox versions does not support the flag, causing the command to fail and the sidecar to hang indefinitely. This commit replaces the command with a portable shell loop that iterates over to identify processes owned by the current user. This ensures compatibility with all Alpine versions and removes the dependency on .
Bug Report: KubernetesPodOperator XCom Sidecar Hangs due to pgrep missing -u option
Title
KubernetesPodOperator XCom sidecar hangs indefinitely because "pgrep -u" is not supported in some Alpine versions
Description
The KubernetesPodOperator injects a sidecar container to capture XCom values. Once the main container completes, Airflow attempts to terminate this sidecar to allow the Pod to complete.
The termination logic in PodManager.extract_xcom_kill executes the following command inside the sidecar:
kill -2$(pgrep -u $ (id -u) -f 'sh')
This command relies on pgrep supporting the -u (user) flag to filter processes by the current user. However, many lightweight container images used for sidecars (like alpine) use BusyBox's implementation of pgrep. Some versions of BusyBox pgrep do not support the -u flag, causing the command to fail with an invalid option error.
As a result:
The kill command fails.
The sidecar container continues running (executing its infinite sleep loop).
The Pod remains in the Running phase.
The Airflow task eventually times out despite the main work completing successfully.
Impact:
Task Hangs: Tasks that successfully finish their work will hang until the operator times out and causing task to fail.
False Failures: Successful tasks are marked as failed due to timeout.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.