1996fanrui commented on code in PR #2243:
URL: 
https://github.com/apache/incubator-streampark/pull/2243#discussion_r1064298652


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -580,6 +583,39 @@ public List<String> historyUploadJars() {
         .collect(Collectors.toList());
   }
 
+  @Override
+  public String k8sStartLog(Long id, Integer offset, Integer limit) throws 
Exception {
+    Application application = getById(id);
+    AssertUtils.state(application != null);
+    if (ExecutionMode.isKubernetesMode(application.getExecutionModeEnum())) {
+      CompletableFutureUtils.supplyTimeout(
+              CompletableFuture.supplyAsync(
+                  () ->
+                      KubernetesDeploymentHelper.watchDeploymentLog(
+                          application.getK8sNamespace(),
+                          application.getJobName(),
+                          application.getJobId())),
+              5,
+              TimeUnit.SECONDS,
+              success -> success,
+              exception -> {
+                String errorLog =
+                    String.format(
+                        "%s/%s_err.log", WebUtils.getAppTempDir(), 
application.getJobId());
+                File file = new File(errorLog);
+                if (file.exists()) {
+                  return errorLog;
+                } else {
+                  throw new ApiDetailException("get k8s job log failed: " + 
exception.getMessage());
+                }
+              })

Review Comment:
   ```suggestion
   
         CompletableFuture future = CompletableFuture.supplyAsync(
                     () ->
                         KubernetesDeploymentHelper.watchDeploymentLog(
                             application.getK8sNamespace(),
                             application.getJobName(),
                             application.getJobId()));
         CompletableFutureUtils.supplyTimeout(future,
                 5,
                 TimeUnit.SECONDS,
                 success -> success,
                 exception -> {
                   String errorLog =
                       String.format(
                           "%s/%s_err.log", WebUtils.getAppTempDir(), 
application.getJobId());
                   File file = new File(errorLog);
                   if (file.exists()) {
                     return errorLog;
                   } else {
                     throw new ApiDetailException("get k8s job log failed: " + 
exception.getMessage());
                   }
                   if (!future.isDone()) {
                     future.cancel(true)
                   }
                 })
   ```
   
   The future need to be cancel after timeout.



-- 
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