[jira] [Commented] (AIRFLOW-5589) KubernetesPodOperator: Duplicate pods created on worker restart
[ https://issues.apache.org/jira/browse/AIRFLOW-5589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17140280#comment-17140280 ] Daniel Cooper commented on AIRFLOW-5589: Hey [~dimberman], thanks for getting the PR for this in. I saw you tagged the PR as in 1.10.11 so assigned this to you & set the fix version so it isn't missed in release notes. > KubernetesPodOperator: Duplicate pods created on worker restart > --- > > Key: AIRFLOW-5589 > URL: https://issues.apache.org/jira/browse/AIRFLOW-5589 > Project: Apache Airflow > Issue Type: Bug > Components: worker >Affects Versions: 1.10.4, 1.10.5 >Reporter: Daniel Cooper >Assignee: Daniel Imberman >Priority: Major > Fix For: 1.10.11 > > > K8sPodOperator holds state within the execute function that monitors the > running pod. If a worker restarts for any reason (pod death, pod shuffle, > upgrade etc.) then this state is lost. > At this point the scheduler notices (after max heartbeat interval wait) that > the task is now 'zombie' (not monitored) and reschedules the task. > The new worker has no knowledge of the existing running pod and so creates a > new duplicate pod. This can lead to many duplicate pods for the same task > running together in extreme cases. > I believe this is the problem Nicholas Brenwald (King) described as having > when running k8s pod operator on Google Composer (at the September meetup at > King). > My fix is to add enough labels to uniquely identify a running pod as being > from a given task instance (dag_id, task_id, run_id). We then do a > namespaced list of pods from k8s with a label selector and monitor the > existing pod if it exists otherwise we create a new one as normal. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (AIRFLOW-5589) KubernetesPodOperator: Duplicate pods created on worker restart
[ https://issues.apache.org/jira/browse/AIRFLOW-5589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17058108#comment-17058108 ] ASF GitHub Bot commented on AIRFLOW-5589: - dimberman commented on pull request #6377: [AIRFLOW-5589] monitor pods by labels instead of names URL: https://github.com/apache/airflow/pull/6377 Make sure you have checked _all_ steps below. ### Jira - [ ] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR" - https://issues.apache.org/jira/browse/AIRFLOW-5589 - In case you are fixing a typo in the documentation you can prepend your commit with \[AIRFLOW-XXX\], code changes always need a Jira issue. - In case you are proposing a fundamental code change, you need to create an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)). - In case you are adding a dependency, check if the license complies with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x). ### Description - [ ] Here are some details about my PR, including screenshots of any UI changes: ### Tests - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason: ### Commits - [ ] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)": 1. Subject is separated from body by a blank line 1. Subject is limited to 50 characters (not including Jira issue reference) 1. Subject does not end with a period 1. Subject uses the imperative mood ("add", not "adding") 1. Body wraps at 72 characters 1. Body explains "what" and "why", not "how" ### Documentation - [ ] In case of new functionality, my PR adds documentation that describes how to use it. - All the public functions and the classes in the PR contain docstrings that explain what it does - If you implement backwards incompatible changes, please leave a note in the [Updating.md](https://github.com/apache/airflow/blob/master/UPDATING.md) so we can assign it to a appropriate release 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > KubernetesPodOperator: Duplicate pods created on worker restart > --- > > Key: AIRFLOW-5589 > URL: https://issues.apache.org/jira/browse/AIRFLOW-5589 > Project: Apache Airflow > Issue Type: Bug > Components: worker >Affects Versions: 1.10.4, 1.10.5 >Reporter: Daniel Cooper >Assignee: Daniel Cooper >Priority: Major > > K8sPodOperator holds state within the execute function that monitors the > running pod. If a worker restarts for any reason (pod death, pod shuffle, > upgrade etc.) then this state is lost. > At this point the scheduler notices (after max heartbeat interval wait) that > the task is now 'zombie' (not monitored) and reschedules the task. > The new worker has no knowledge of the existing running pod and so creates a > new duplicate pod. This can lead to many duplicate pods for the same task > running together in extreme cases. > I believe this is the problem Nicholas Brenwald (King) described as having > when running k8s pod operator on Google Composer (at the September meetup at > King). > My fix is to add enough labels to uniquely identify a running pod as being > from a given task instance (dag_id, task_id, run_id). We then do a > namespaced list of pods from k8s with a label selector and monitor the > existing pod if it exists otherwise we create a new one as normal. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (AIRFLOW-5589) KubernetesPodOperator: Duplicate pods created on worker restart
[ https://issues.apache.org/jira/browse/AIRFLOW-5589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17008059#comment-17008059 ] ASF GitHub Bot commented on AIRFLOW-5589: - stale[bot] commented on pull request #6377: [AIRFLOW-5589] monitor pods by labels instead of names URL: https://github.com/apache/airflow/pull/6377 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > KubernetesPodOperator: Duplicate pods created on worker restart > --- > > Key: AIRFLOW-5589 > URL: https://issues.apache.org/jira/browse/AIRFLOW-5589 > Project: Apache Airflow > Issue Type: Bug > Components: worker >Affects Versions: 1.10.4, 1.10.5 >Reporter: Daniel Cooper >Assignee: Daniel Cooper >Priority: Major > > K8sPodOperator holds state within the execute function that monitors the > running pod. If a worker restarts for any reason (pod death, pod shuffle, > upgrade etc.) then this state is lost. > At this point the scheduler notices (after max heartbeat interval wait) that > the task is now 'zombie' (not monitored) and reschedules the task. > The new worker has no knowledge of the existing running pod and so creates a > new duplicate pod. This can lead to many duplicate pods for the same task > running together in extreme cases. > I believe this is the problem Nicholas Brenwald (King) described as having > when running k8s pod operator on Google Composer (at the September meetup at > King). > My fix is to add enough labels to uniquely identify a running pod as being > from a given task instance (dag_id, task_id, run_id). We then do a > namespaced list of pods from k8s with a label selector and monitor the > existing pod if it exists otherwise we create a new one as normal. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (AIRFLOW-5589) KubernetesPodOperator: Duplicate pods created on worker restart
[ https://issues.apache.org/jira/browse/AIRFLOW-5589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16955995#comment-16955995 ] ASF GitHub Bot commented on AIRFLOW-5589: - dimberman commented on pull request #6377: AIRFLOW-5589 monitor pods by labels instead of names URL: https://github.com/apache/airflow/pull/6377 Make sure you have checked _all_ steps below. ### Jira - [ ] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR" - https://issues.apache.org/jira/browse/AIRFLOW-XXX - In case you are fixing a typo in the documentation you can prepend your commit with \[AIRFLOW-XXX\], code changes always need a Jira issue. - In case you are proposing a fundamental code change, you need to create an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)). - In case you are adding a dependency, check if the license complies with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x). ### Description - [ ] Here are some details about my PR, including screenshots of any UI changes: ### Tests - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason: ### Commits - [ ] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)": 1. Subject is separated from body by a blank line 1. Subject is limited to 50 characters (not including Jira issue reference) 1. Subject does not end with a period 1. Subject uses the imperative mood ("add", not "adding") 1. Body wraps at 72 characters 1. Body explains "what" and "why", not "how" ### Documentation - [ ] In case of new functionality, my PR adds documentation that describes how to use it. - All the public functions and the classes in the PR contain docstrings that explain what it does - If you implement backwards incompatible changes, please leave a note in the [Updating.md](https://github.com/apache/airflow/blob/master/UPDATING.md) so we can assign it to a appropriate release 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > KubernetesPodOperator: Duplicate pods created on worker restart > --- > > Key: AIRFLOW-5589 > URL: https://issues.apache.org/jira/browse/AIRFLOW-5589 > Project: Apache Airflow > Issue Type: Bug > Components: worker >Affects Versions: 1.10.4, 1.10.5 >Reporter: Daniel Cooper >Assignee: Daniel Cooper >Priority: Major > > K8sPodOperator holds state within the execute function that monitors the > running pod. If a worker restarts for any reason (pod death, pod shuffle, > upgrade etc.) then this state is lost. > At this point the scheduler notices (after max heartbeat interval wait) that > the task is now 'zombie' (not monitored) and reschedules the task. > The new worker has no knowledge of the existing running pod and so creates a > new duplicate pod. This can lead to many duplicate pods for the same task > running together in extreme cases. > I believe this is the problem Nicholas Brenwald (King) described as having > when running k8s pod operator on Google Composer (at the September meetup at > King). > My fix is to add enough labels to uniquely identify a running pod as being > from a given task instance (dag_id, task_id, run_id). We then do a > namespaced list of pods from k8s with a label selector and monitor the > existing pod if it exists otherwise we create a new one as normal. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (AIRFLOW-5589) KubernetesPodOperator: Duplicate pods created on worker restart
[ https://issues.apache.org/jira/browse/AIRFLOW-5589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16943462#comment-16943462 ] Daniel Cooper commented on AIRFLOW-5589: I've done a fix for this in our extension of the k8s pod operator. I've ported this into the v1-10-stable branch: [https://github.com/danccooper/airflow/commit/26424705ac368056ff0d66a2f37337aa533dec86] I've not tested this at all in the airflow project itself but wanted to make it available for others to use if they need to. There is at least one thing to tidy up (usage of 'private' function _monitor_pod() from PodLauncher) and probably more. Hopefully I will have time soon to get a local env running for airflow and polish the contribution, if anyone else wants to pick this up & continue please do. > KubernetesPodOperator: Duplicate pods created on worker restart > --- > > Key: AIRFLOW-5589 > URL: https://issues.apache.org/jira/browse/AIRFLOW-5589 > Project: Apache Airflow > Issue Type: Bug > Components: worker >Affects Versions: 1.10.4, 1.10.5 >Reporter: Daniel Cooper >Assignee: Daniel Cooper >Priority: Major > > K8sPodOperator holds state within the execute function that monitors the > running pod. If a worker restarts for any reason (pod death, pod shuffle, > upgrade etc.) then this state is lost. > At this point the scheduler notices (after max heartbeat interval wait) that > the task is now 'zombie' (not monitored) and reschedules the task. > The new worker has no knowledge of the existing running pod and so creates a > new duplicate pod. This can lead to many duplicate pods for the same task > running together in extreme cases. > I believe this is the problem Nicholas Brenwald (King) described as having > when running k8s pod operator on Google Composer (at the September meetup at > King). > My fix is to add enough labels to uniquely identify a running pod as being > from a given task instance (dag_id, task_id, run_id). We then do a > namespaced list of pods from k8s with a label selector and monitor the > existing pod if it exists otherwise we create a new one as normal. -- This message was sent by Atlassian Jira (v8.3.4#803005)