stijndehaes opened a new issue #10544:
URL: https://github.com/apache/airflow/issues/10544
<!--
Welcome to Apache Airflow! For a smooth issue process, try to answer the
following questions.
Don't worry if they're not all applicable; just try to include what you can
:-)
If you need to include code snippets or logs, please put them in fenced code
blocks. If they're super-long, please use the details tag like
<details><summary>super-long log</summary> lots of stuff </details>
Please delete these comment blocks before submitting the issue.
-->
<!--
IMPORTANT!!!
PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
Please complete the next sections or the issue will be closed.
This questions are the first thing we need to know to understand the context.
-->
**Apache Airflow version**: 1.10.11
**Kubernetes version (if you are using kubernetes)** (use `kubectl
version`):
```
Server Version: version.Info{Major:"1", Minor:"17+",
GitVersion:"v1.17.9-eks-4c6976",
GitCommit:"4c6976793196d70bc5cd29d56ce5440c9473648e", GitTreeState:"clean",
BuildDate:"2020-07-17T18:46:04Z", GoVersion:"go1.13.9", Compiler:"gc",
Platform:"linux/amd64"}
```
**Environment**:
- **Cloud provider or hardware configuration**: AWS
- **OS** (e.g. from /etc/os-release): not relevant
- **Kernel** (e.g. `uname -a`): not relevant
- **Install tools**: not relevant
- **Others**: not relevant
**What happened**:
<!-- (please include exact error messages if you can) -->
When launching a failing kubernetesPodOperator job with 4 retries you get
the following message on the second retry. This is because the failed pods
still exist on kubernetes and thus the list call in the pod operator:
```python
pod_list = client.list_namespaced_pod(self.namespace,
label_selector=label_selector)
```
Also returns the failed objects. A fix would be to filter on only pods that
are not completed or failed.
```
[2020-08-25 08:51:17,856] {taskinstance.py:1150} ERROR - Pod Launching
failed: More than one pod running with labels:
dag_id=sample-python-failing,execution_date=2020-08-24T0300000000-71ba3e273,task_id=ingest-weather
Traceback (most recent call last):
File
"/usr/local/lib/python3.7/site-packages/airflow/contrib/operators/kubernetes_pod_operator.py",
line 276, in execute
'{label_selector}'.format(label_selector=label_selector))
airflow.exceptions.AirflowException: More than one pod running with labels:
dag_id=sample-python-failing,execution_date=2020-08-24T0300000000-71ba3e273,task_id=ingest-weather
```
**What you expected to happen**:
To start my container anew.
<!-- What do you think went wrong? -->
**How to reproduce it**:
To reproduce start a dag with a kubernetespodoperator with retries that
fails. Set the retries to more then 2 as it starts happening on the thrid try.
<!---
As minimally and precisely as possible. Keep in mind we do not have access
to your cluster or dags.
If you are using kubernetes, please attempt to recreate the issue using
minikube or kind.
## Install minikube/kind
- Minikube https://minikube.sigs.k8s.io/docs/start/
- Kind https://kind.sigs.k8s.io/docs/user/quick-start/
If this is a UI bug, please provide a screenshot of the bug or a link to a
youtube video of the bug in action
You can include images using the .md style of

To record a screencast, mac users can use QuickTime and then create an
unlisted youtube video with the resulting .mov file.
--->
**Anything else we need to know**:
<!--
How often does this problem occur? Once? Every time etc?
Any relevant logs to include? Put them here in side a detail tag:
<details><summary>x.log</summary> lots of stuff </details>
-->
I will make a PR myself to fix this.
----------------------------------------------------------------
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:
[email protected]