You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/08/30 07:03:56 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #25882: Prevent `KubernetesPodOperator` from finding pods with the wrong name

uranusjr commented on code in PR #25882:
URL: https://github.com/apache/airflow/pull/25882#discussion_r958082159


##########
airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py:
##########
@@ -370,11 +370,11 @@ def find_pod(
             label_selector=label_selector,
         ).items
 
-        pod = None
+        pod: Optional[k8s.V1Pod] = None
         num_pods = len(pod_list)
         if num_pods > 1:
             raise AirflowException(f'More than one pod running with labels {label_selector}')
-        elif num_pods == 1:
+        elif num_pods == 1 and pod_list[0].metadata.name.startswith(self.name):
             pod = pod_list[0]
             self.log.info("Found matching pod %s with labels %s", pod.metadata.name, pod.metadata.labels)
             self.log.info("`try_number` of task_instance: %s", context['ti'].try_number)

Review Comment:
   We should also log something if a pod is found but under the wrong name so the user can understand the context better when debugging.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org