You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2024/08/02 07:33:01 UTC

(kyuubi) branch master updated: [KYUUBI #6579] Show kyuubi batch app details on app state change

This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 2a990beb7 [KYUUBI #6579] Show kyuubi batch app details on app state change
2a990beb7 is described below

commit 2a990beb714f4196dffb62983694b271865333df
Author: Wang, Fei <fw...@ebay.com>
AuthorDate: Fri Aug 2 00:32:54 2024 -0700

    [KYUUBI #6579] Show kyuubi batch app details on app state change
    
    # :mag: Description
    ## Issue References ๐Ÿ”—
    
    This pr enhance the kyuubi batch logs for spark on k8s with kyuubi-ctl.
    ## Describe Your Solution ๐Ÿ”ง
    
    For spark on k8s, before, it does not show the app detail info until the log batch command finished.
    
    In this PR, it will show the batch app details in app state change.
    
    Especially show the app URL info.
    
    ## Types of changes :bookmark:
    
    - [ ] Bugfix (non-breaking change which fixes an issue)
    - [x] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing functionality to change)
    
    ## Test Plan ๐Ÿงช
    
    #### Behavior Without This Pull Request :coffin:
    
    #### Behavior With This Pull Request :tada:
    
    #### Related Unit Tests
    <img width="1326" alt="image" src="https://github.com/user-attachments/assets/2356af83-4422-4dfc-812c-d90b809ea724">
    
    ---
    
    # Checklist ๐Ÿ“
    
    - [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)
    
    **Be nice. Be informative.**
    
    Closes #6579 from turboFei/print_batch_report.
    
    Closes #6579
    
    0651dad18 [Wang, Fei] show app details on app state change
    
    Authored-by: Wang, Fei <fw...@ebay.com>
    Signed-off-by: Wang, Fei <fw...@ebay.com>
---
 .../scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala     | 8 ++++++++
 kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/util/Render.scala | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala
index f4ce390df..2e3f68b77 100644
--- a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala
+++ b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala
@@ -20,6 +20,8 @@ import java.util.{Map => JMap}
 
 import scala.collection.JavaConverters._
 
+import org.apache.commons.lang3.StringUtils
+
 import org.apache.kyuubi.client.BatchRestApi
 import org.apache.kyuubi.client.api.v1.dto.{Batch, OperationLog}
 import org.apache.kyuubi.client.util.BatchUtils
@@ -50,6 +52,7 @@ class LogBatchCommand(
 
       var done = false
       var batch = this.batch.getOrElse(batchRestApi.getBatchById(batchId))
+      var appState = this.batch.map(_.getAppState).orNull
       val kyuubiInstance = batch.getKyuubiInstance
 
       withKyuubiInstanceRestClient(kyuubiRestClient, kyuubiInstance) { kyuubiInstanceRestClient =>
@@ -85,6 +88,11 @@ class LogBatchCommand(
               Option(batch).foreach { batch =>
                 info(s"Application report for ${batch.getAppId} (state: ${batch.getAppState})," +
                   s" batch id: $batchId (state: ${batch.getState})")
+                if (appState != batch.getAppState && StringUtils.isNotBlank(batch.getAppId)) {
+                  appState = batch.getAppState
+                  val appDetails = Render.buildBatchAppInfo(batch).mkString("\t ", "\n\t ", "")
+                  info(appDetails)
+                }
               }
             }
             Thread.sleep(conf.get(CTL_BATCH_LOG_QUERY_INTERVAL))
diff --git a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/util/Render.scala b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/util/Render.scala
index 92db46d88..c2a10e6b8 100644
--- a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/util/Render.scala
+++ b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/util/Render.scala
@@ -122,7 +122,7 @@ private[ctl] object Render {
         millisToDateString(batch.getEndTime, "yyyy-MM-dd HH:mm:ss")).mkString("\n~\n"))
   }
 
-  private def buildBatchAppInfo(batch: Batch, showDiagnostic: Boolean = true): List[String] = {
+  def buildBatchAppInfo(batch: Batch, showDiagnostic: Boolean = true): List[String] = {
     val batchAppInfo = ListBuffer[String]()
     batch.getBatchInfo.asScala.foreach { case (key, value) =>
       batchAppInfo += s"$key: $value"