You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@streampark.apache.org by GitBox <gi...@apache.org> on 2023/01/08 15:37:36 UTC

[GitHub] [incubator-streampark] 1996fanrui commented on a diff in pull request #2243: [Improve] read flink on k8s deploy log improvement

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: issues-unsubscribe@streampark.apache.org

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