Gallardot commented on code in PR #14379:
URL: 
https://github.com/apache/dolphinscheduler/pull/14379#discussion_r1259094240


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/am/KubernetesApplicationManager.java:
##########
@@ -180,16 +182,25 @@ private TaskExecutionStatus 
getApplicationStatus(KubernetesApplicationManagerCon
      */
     public LogWatch getPodLogWatcher(KubernetesApplicationManagerContext 
kubernetesApplicationManagerContext) {
         KubernetesClient client = 
getClient(kubernetesApplicationManagerContext);
-        FilterWatchListDeletable<Pod, PodList, PodResource> watchList =
-                getDriverPod(kubernetesApplicationManagerContext);
-        List<Pod> driverPod = watchList.list().getItems();
-        if (CollectionUtils.isEmpty(driverPod)) {
-            return null;
+        boolean podIsReady = false;
+        Pod pod = null;
+        while (!podIsReady) {
+            FilterWatchListDeletable<Pod, PodList, PodResource> watchList =
+                    getListenPod(kubernetesApplicationManagerContext);
+            List<Pod> podList = watchList.list().getItems();
+            if (CollectionUtils.isEmpty(podList)) {
+                return null;
+            }
+            pod = podList.get(0);
+            if (pod.getStatus().getPhase().equals(PENDING)) {
+                ThreadUtils.sleep(SLEEP_TIME_MILLIS);
+            } else {
+                podIsReady = true;
+            }
         }
-        Pod driver = driverPod.get(0);
 
-        return client.pods().inNamespace(driver.getMetadata().getNamespace())
-                .withName(driver.getMetadata().getName())
+        return client.pods().inNamespace(pod.getMetadata().getNamespace())
+                .withName(pod.getMetadata().getName())

Review Comment:
   Add inContainer() to further specify the task container for the pod. In some 
environments, the infrastructure may automatically add sidecar containers. If 
the container is not specified, an exception occurs.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/am/KubernetesApplicationManager.java:
##########
@@ -180,16 +182,25 @@ private TaskExecutionStatus 
getApplicationStatus(KubernetesApplicationManagerCon
      */
     public LogWatch getPodLogWatcher(KubernetesApplicationManagerContext 
kubernetesApplicationManagerContext) {
         KubernetesClient client = 
getClient(kubernetesApplicationManagerContext);
-        FilterWatchListDeletable<Pod, PodList, PodResource> watchList =
-                getDriverPod(kubernetesApplicationManagerContext);
-        List<Pod> driverPod = watchList.list().getItems();
-        if (CollectionUtils.isEmpty(driverPod)) {
-            return null;
+        boolean podIsReady = false;
+        Pod pod = null;
+        while (!podIsReady) {
+            FilterWatchListDeletable<Pod, PodList, PodResource> watchList =
+                    getListenPod(kubernetesApplicationManagerContext);
+            List<Pod> podList = watchList.list().getItems();
+            if (CollectionUtils.isEmpty(podList)) {
+                return null;

Review Comment:
   Should not return directly, perhaps the k8s controller manager is currently 
under high system load, and the scheduling is a little slow.
   
   We should wait and retry, but of course we should set a reasonable number of 
retries.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to