e-galan commented on code in PR #39329:
URL: https://github.com/apache/airflow/pull/39329#discussion_r1625700546


##########
airflow/providers/cncf/kubernetes/operators/pod.py:
##########
@@ -533,24 +539,31 @@ def find_pod(self, namespace: str, context: Context, *, 
exclude_checked: bool =
 
         pod = 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:
+
+        if num_pods == 1:
             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)
-            self.log.info("`try_number` of pod: %s", 
pod.metadata.labels["try_number"])
+            self.log_matching_pod(pod=pod, context=context)
+        elif num_pods > 1 and not self.reattach_on_restart:
+            self.log.warning("Found more than one pod running with labels %s, 
resolving ...", label_selector)
+            pod = self.process_duplicate_label_pods(pod_list)
+            self.log_matching_pod(pod=pod, context=context)
+        elif num_pods > 1:
+            raise IdenticalLabelPodError(f"More than one pod running with 
labels {label_selector}")
+

Review Comment:
   Rephrased with some improvements:)
   Thank you for the suggestion @shahar1 !



-- 
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-unsubscr...@airflow.apache.org

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

Reply via email to