You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2021/07/30 08:17:03 UTC

[GitHub] [incubator-kyuubi] ulysses-you opened a new pull request #875: Enhance kubernetes cluster diagnostics

ulysses-you opened a new pull request #875:
URL: https://github.com/apache/incubator-kyuubi/pull/875


   <!--
   Thanks for sending a pull request!
   
   Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
     2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
   -->
   
   ### _Why are the changes needed?_
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you add a feature, you can talk about the use case of it.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   Add kubernetes context and namespace info if Spark is running on k8s.
   
   ### _How was this patch tested?_
   - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
   
   - [ ] Add screenshots for manual tests if appropriate
   
   - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/tools/testing.html#running-tests) locally before make a pull request
   


-- 
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: commits-unsubscribe@kyuubi.apache.org

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



[GitHub] [incubator-kyuubi] codecov-commenter commented on pull request #875: Enhance kubernetes cluster diagnostics

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #875:
URL: https://github.com/apache/incubator-kyuubi/pull/875#issuecomment-889735807


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#875](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0e5ed27) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/f4fb822743e77554ffca40fbe571e77cac4acbe8?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f4fb822) will **decrease** coverage by `0.08%`.
   > The diff coverage is `25.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #875      +/-   ##
   ============================================
   - Coverage     78.68%   78.60%   -0.09%     
     Complexity       10       10              
   ============================================
     Files           135      137       +2     
     Lines          5151     5201      +50     
     Branches        644      645       +1     
   ============================================
   + Hits           4053     4088      +35     
   - Misses          746      758      +12     
   - Partials        352      355       +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...g/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9LeXV1YmlTcGFya1V0aWwuc2NhbGE=) | `61.11% <25.00%> (-29.80%)` | :arrow_down: |
   | [...org/apache/kyuubi/operation/OperationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vT3BlcmF0aW9uTWFuYWdlci5zY2FsYQ==) | `74.19% <0.00%> (-2.48%)` | :arrow_down: |
   | [...rg/apache/kyuubi/engine/spark/SparkSQLEngine.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9TcGFya1NRTEVuZ2luZS5zY2FsYQ==) | `71.87% <0.00%> (-1.98%)` | :arrow_down: |
   | [...ala/org/apache/kyuubi/session/SessionManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXNzaW9uL1Nlc3Npb25NYW5hZ2VyLnNjYWxh) | `52.94% <0.00%> (ø)` | |
   | [.../scala/org/apache/spark/kyuubi/ui/EnginePage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUvc3Bhcmsva3l1dWJpL3VpL0VuZ2luZVBhZ2Uuc2NhbGE=) | `96.55% <0.00%> (ø)` | |
   | [...n/scala/org/apache/spark/kyuubi/ui/EngineTab.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUvc3Bhcmsva3l1dWJpL3VpL0VuZ2luZVRhYi5zY2FsYQ==) | `85.71% <0.00%> (ø)` | |
   | [...org/apache/spark/kyuubi/SQLOperationListener.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUvc3Bhcmsva3l1dWJpL1NRTE9wZXJhdGlvbkxpc3RlbmVyLnNjYWxh) | `93.87% <0.00%> (+2.04%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [f4fb822...0e5ed27](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: commits-unsubscribe@kyuubi.apache.org

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



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #875: Enhance kubernetes cluster diagnostics

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #875:
URL: https://github.com/apache/incubator-kyuubi/pull/875#discussion_r679810523



##########
File path: externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala
##########
@@ -19,13 +19,39 @@ package org.apache.kyuubi.engine.spark
 
 import java.time.{Instant, LocalDateTime, ZoneId}
 
+import org.apache.spark.SparkContext
 import org.apache.spark.sql.SparkSession
 
 object KyuubiSparkUtil {
+  // Regular expression for connecting to kubernetes clusters
+  val KUBERNETES_REGEX = """k8s://(.*)""".r
 
   lazy val diagnostics: String = {
-    val spark = SparkSession.active
-    val sc = spark.sparkContext
+    val sc = SparkSession.active.sparkContext
+
+    sc.master match {
+      case KUBERNETES_REGEX(_) => getKubernetesClusterInfo(sc)
+      case _ => defaultClusterInfo(sc)
+    }
+  }
+
+  def getKubernetesClusterInfo(sc: SparkContext): String = {
+    // scalastyle:off line.size.limit
+    s"""
+       |           Spark application name: ${sc.appName}
+       |                 application ID:  ${sc.applicationId}
+       |                 application web UI: ${sc.uiWebUrl}
+       |                 master: ${sc.master}
+       |                 deploy mode: ${sc.deployMode}
+       |                 context: ${sc.getConf.getOption("spark.kubernetes.context").getOrElse("default")}
+       |                 namespace: ${sc.getConf.getOption("spark.kubernetes.namespace").getOrElse("default")}
+       |                 version: ${sc.version}
+       |           Start time: ${LocalDateTime.ofInstant(Instant.ofEpochMilli(sc.startTime), ZoneId.systemDefault)}
+       |           User: ${sc.sparkUser}""".stripMargin
+    // scalastyle:on line.size.limit
+  }
+
+  def defaultClusterInfo(sc: SparkContext): String = {

Review comment:
       can we reduce the duplicated code?




-- 
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: commits-unsubscribe@kyuubi.apache.org

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



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #875: Enhance kubernetes cluster diagnostics

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #875:
URL: https://github.com/apache/incubator-kyuubi/pull/875#issuecomment-889735807


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#875](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (1d21798) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/f4fb822743e77554ffca40fbe571e77cac4acbe8?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f4fb822) will **decrease** coverage by `0.08%`.
   > The diff coverage is `72.41%`.
   
   > :exclamation: Current head 1d21798 differs from pull request most recent head bcd6aa8. Consider uploading reports for the commit bcd6aa8 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #875      +/-   ##
   ============================================
   - Coverage     78.68%   78.60%   -0.09%     
     Complexity       10       10              
   ============================================
     Files           135      137       +2     
     Lines          5151     5201      +50     
     Branches        644      645       +1     
   ============================================
   + Hits           4053     4088      +35     
   - Misses          746      758      +12     
   - Partials        352      355       +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...org/apache/kyuubi/operation/OperationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vT3BlcmF0aW9uTWFuYWdlci5zY2FsYQ==) | `74.19% <0.00%> (-2.48%)` | :arrow_down: |
   | [...n/scala/org/apache/kyuubi/service/Serverable.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2aWNlL1NlcnZlcmFibGUuc2NhbGE=) | `44.44% <ø> (ø)` | |
   | [...ala/org/apache/kyuubi/session/SessionManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXNzaW9uL1Nlc3Npb25NYW5hZ2VyLnNjYWxh) | `52.94% <ø> (ø)` | |
   | [...g/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9LeXV1YmlTcGFya1V0aWwuc2NhbGE=) | `61.11% <25.00%> (-29.80%)` | :arrow_down: |
   | [...rg/apache/kyuubi/engine/spark/SparkSQLEngine.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9TcGFya1NRTEVuZ2luZS5zY2FsYQ==) | `71.87% <66.66%> (-1.98%)` | :arrow_down: |
   | [...n/scala/org/apache/spark/kyuubi/ui/EngineTab.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUvc3Bhcmsva3l1dWJpL3VpL0VuZ2luZVRhYi5zY2FsYQ==) | `85.71% <85.71%> (ø)` | |
   | [.../scala/org/apache/spark/kyuubi/ui/EnginePage.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUvc3Bhcmsva3l1dWJpL3VpL0VuZ2luZVBhZ2Uuc2NhbGE=) | `96.55% <96.55%> (ø)` | |
   | [...ommon/src/main/scala/org/apache/kyuubi/Utils.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9VdGlscy5zY2FsYQ==) | `73.41% <100.00%> (ø)` | |
   | [.../scala/org/apache/kyuubi/server/KyuubiServer.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpU2VydmVyLnNjYWxh) | `50.00% <100.00%> (ø)` | |
   | ... and [2 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/875/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [f4fb822...bcd6aa8](https://codecov.io/gh/apache/incubator-kyuubi/pull/875?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: commits-unsubscribe@kyuubi.apache.org

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



[GitHub] [incubator-kyuubi] ulysses-you closed pull request #875: Enhance kubernetes cluster diagnostics

Posted by GitBox <gi...@apache.org>.
ulysses-you closed pull request #875:
URL: https://github.com/apache/incubator-kyuubi/pull/875


   


-- 
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: commits-unsubscribe@kyuubi.apache.org

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



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #875: Enhance kubernetes cluster diagnostics

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #875:
URL: https://github.com/apache/incubator-kyuubi/pull/875#discussion_r679809759



##########
File path: externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala
##########
@@ -19,13 +19,39 @@ package org.apache.kyuubi.engine.spark
 
 import java.time.{Instant, LocalDateTime, ZoneId}
 
+import org.apache.spark.SparkContext
 import org.apache.spark.sql.SparkSession
 
 object KyuubiSparkUtil {
+  // Regular expression for connecting to kubernetes clusters
+  val KUBERNETES_REGEX = """k8s://(.*)""".r
 
   lazy val diagnostics: String = {
-    val spark = SparkSession.active
-    val sc = spark.sparkContext
+    val sc = SparkSession.active.sparkContext
+
+    sc.master match {
+      case KUBERNETES_REGEX(_) => getKubernetesClusterInfo(sc)
+      case _ => defaultClusterInfo(sc)
+    }
+  }
+
+  def getKubernetesClusterInfo(sc: SparkContext): String = {
+    // scalastyle:off line.size.limit
+    s"""
+       |           Spark application name: ${sc.appName}
+       |                 application ID:  ${sc.applicationId}
+       |                 application web UI: ${sc.uiWebUrl}
+       |                 master: ${sc.master}
+       |                 deploy mode: ${sc.deployMode}
+       |                 context: ${sc.getConf.getOption("spark.kubernetes.context").getOrElse("default")}

Review comment:
       get("spark.kubernetes.context", "default")

##########
File path: externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala
##########
@@ -19,13 +19,39 @@ package org.apache.kyuubi.engine.spark
 
 import java.time.{Instant, LocalDateTime, ZoneId}
 
+import org.apache.spark.SparkContext
 import org.apache.spark.sql.SparkSession
 
 object KyuubiSparkUtil {
+  // Regular expression for connecting to kubernetes clusters
+  val KUBERNETES_REGEX = """k8s://(.*)""".r
 
   lazy val diagnostics: String = {
-    val spark = SparkSession.active
-    val sc = spark.sparkContext
+    val sc = SparkSession.active.sparkContext
+
+    sc.master match {
+      case KUBERNETES_REGEX(_) => getKubernetesClusterInfo(sc)
+      case _ => defaultClusterInfo(sc)
+    }
+  }
+
+  def getKubernetesClusterInfo(sc: SparkContext): String = {
+    // scalastyle:off line.size.limit
+    s"""
+       |           Spark application name: ${sc.appName}
+       |                 application ID:  ${sc.applicationId}
+       |                 application web UI: ${sc.uiWebUrl}
+       |                 master: ${sc.master}
+       |                 deploy mode: ${sc.deployMode}
+       |                 context: ${sc.getConf.getOption("spark.kubernetes.context").getOrElse("default")}
+       |                 namespace: ${sc.getConf.getOption("spark.kubernetes.namespace").getOrElse("default")}

Review comment:
       ditto




-- 
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: commits-unsubscribe@kyuubi.apache.org

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