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


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -580,6 +584,36 @@ 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())) {
+      CompletionStage<String> stage =
+          CompletableFuture.supplyAsync(
+                  () ->
+                      KubernetesDeploymentHelper.watchDeploymentLog(
+                          application.getK8sNamespace(),
+                          application.getJobName(),
+                          application.getJobId()))
+              .exceptionally(
+                  e -> {
+                    try {
+                      return String.format(
+                          "%s/%s_err.log", WebUtils.getAppTempDir(), 
application.getJobId());
+                    } catch (Exception ex) {
+                      throw new ApiDetailException(
+                          "Generate log path exception: " + ex.getMessage());
+                    }
+                  })
+              .thenApply(path -> logClient.rollViewLog(String.valueOf(path), 
offset, limit));
+      CompletableFuture<String> future = stage.toCompletableFuture();

Review Comment:
   ```suggestion
         CompletableFuture<String> future =
             CompletableFuture.supplyAsync(
                     () ->
                         KubernetesDeploymentHelper.watchDeploymentLog(
                             application.getK8sNamespace(),
                             application.getJobName(),
                             application.getJobId()))
                 .exceptionally(
                     e -> {
                       try {
                         return String.format(
                             "%s/%s_err.log", WebUtils.getAppTempDir(), 
application.getJobId());
                       } catch (Exception ex) {
                         throw new ApiDetailException(
                             "Generate log path exception: " + ex.getMessage());
                       }
                     })
                 .thenApply(path -> logClient.rollViewLog(String.valueOf(path), 
offset, limit));
   ```



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ApplicationServiceImpl.java:
##########
@@ -580,6 +584,36 @@ 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())) {
+      CompletionStage<String> stage =
+          CompletableFuture.supplyAsync(
+                  () ->
+                      KubernetesDeploymentHelper.watchDeploymentLog(
+                          application.getK8sNamespace(),
+                          application.getJobName(),
+                          application.getJobId()))
+              .exceptionally(
+                  e -> {
+                    try {
+                      return String.format(
+                          "%s/%s_err.log", WebUtils.getAppTempDir(), 
application.getJobId());
+                    } catch (Exception ex) {
+                      throw new ApiDetailException(
+                          "Generate log path exception: " + ex.getMessage());
+                    }
+                  })
+              .thenApply(path -> logClient.rollViewLog(String.valueOf(path), 
offset, limit));
+      CompletableFuture<String> future = stage.toCompletableFuture();
+      return future.get(5, TimeUnit.SECONDS);

Review Comment:
   Should we cancel the future 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