Updated kuberentes pod operator to find pods only in running state
The proposed changes to the find_pod method will ensure it selects only pods that are in the running state, effectively ignoring pods that are in the terminating state. This adjustment addresses the issue of pods remaining in the terminating state for an extended period.
closes: https://github.com/apache/airflow/issues/39096 related: https://github.com/apache/airflow/issues/39096
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) Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
- In case of a new feature add useful documentation (in docstrings or in
docs/directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it. - Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the Airflow Coding style.
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits. Apache Airflow is a community-driven project and together we are making it better 🚀. In case of doubts contact the developers at: Mailing List: [email protected] Slack: https://s.apache.org/airflow-slack
@dirrao , please help to review the above changes.
This adjustment addresses the issue of pods remaining in the terminating state for an extended period.
Is that right? Completed is also terminated state is it not? Why reataching to completed pod is considered wrong?
@eladkal , When a node is drained in eks due to aws ec2 spot instance interruption or due to some other reasons , usually controllers will detect that the pods have been terminated and will schedule new pods on other available nodes to maintain the desired number of replicas but in our our case airflow deploy pods without controller. So , sometimes the pods stuck in terminating state for a while till kubernetes reconsiders it and terminates after a node is terminated
The issue I'm trying to address is the above case where the pods are stuck in terminating state and not the completed ones , the find_pod method is used to get pods based on labels and later used in cleanup method.
@paramjeet01 We have retries with retry_delay of 5 mins. If the pod is still stuck in terminating state or whatever, then Kubernetes cluster is not working as expected. I believe we can't handle all these kind of situations in the airflow. Better to fix this issue in Kubernetes. @jedcunningham / @hussein-awala WDYT?
@dirrao Agreed , We can check the kubernetes and solve this issue but we have an existing problem of creating pods on each retry and not cleaned up properly when the find pod returns more than one pod.
Can you add tests for this change?
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.