Skip to content

Commit

Permalink
[KYUUBI #6579] Show kyuubi batch app details on app state change
Browse files Browse the repository at this point in the history
# 🔍 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 🔖

- [ ] 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 ⚰️

#### Behavior With This Pull Request 🎉

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

0651dad [Wang, Fei] show app details on app state change

Authored-by: Wang, Fei <[email protected]>
Signed-off-by: Wang, Fei <[email protected]>
  • Loading branch information
turboFei committed Aug 2, 2024
1 parent c94f0d7 commit 2a990be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =>
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2a990be

Please sign in to comment.