pan3793 commented on code in PR #5168:
URL: https://github.com/apache/kyuubi/pull/5168#discussion_r1295662576


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilder.scala:
##########
@@ -208,6 +210,42 @@ class SparkProcessBuilder(
       kubernetesNamespace())
   }
 
+  def appendPodNameConf(conf: Map[String, String]): Map[String, String] = {
+    val map = mutable.Map.newBuilder[String, String]
+    def appendOptionPair(pairOpt: Option[(String, String)]): Unit = {
+      pairOpt match {
+        case Some(pair) => map += (pair._1 -> pair._2)
+        case _ =>
+      }
+    }
+    if (clusterManager().exists(cm => 
cm.toLowerCase(Locale.ROOT).startsWith("k8s"))) {
+      appendOptionPair(getExecutorPodPrefix(conf))
+      if (deployMode().exists(_.toLowerCase(Locale.ROOT) == "cluster")) {
+        appendOptionPair(getDriverPodPrefix(conf))
+      }
+    }
+    map.result().toMap
+  }
+
+  def getDriverPodPrefix(conf: Map[String, String]): Option[(String, String)] 
= {
+    conf.get(KUBERNETES_DRIVER_POD_NAME) match {
+      // spark app name always be set
+      case None => Some(
+          KUBERNETES_DRIVER_POD_NAME ->
+            KubernetesUtils.generateDriverPodName(conf(APP_KEY), engineRefId))
+      case _ => None
+    }
+  }
+
+  def getExecutorPodPrefix(conf: Map[String, String]): Option[(String, 
String)] = {
+    conf.get(KUBERNETES_EXECUTOR_POD_NAME_PREFIX) match {
+      case None => Some(
+          KUBERNETES_EXECUTOR_POD_NAME_PREFIX ->
+            KubernetesUtils.generateExecutorPodNamePrefix(conf(APP_KEY), 
engineRefId))
+      case _ => None
+    }
+  }

Review Comment:
   ```suggestion
     def appendPodNameConf(conf: Map[String, String]): Map[String, String] = {
       val map = mutable.Map.newBuilder[String, String]
       if (clusterManager().exists(cm => 
cm.toLowerCase(Locale.ROOT).startsWith("k8s"))) {
         getExecutorPodPrefix(conf).foreach { case (k, v) => map += (k, v) }
         if (deployMode().exists(_.toLowerCase(Locale.ROOT) == "cluster")) {
           getDriverPodPrefix(conf).foreach { case (k, v) => map += (k, v) }
         }
       }
       map.result().toMap
     }
   
     def getDriverPodPrefix(conf: Map[String, String]): Option[(String, 
String)] = {
       conf.get(KUBERNETES_DRIVER_POD_NAME) match {
         case None => // skip setting if provided
           val name = KubernetesUtils.generateDriverPodName(conf(APP_KEY), 
engineRefId)
           Some(KUBERNETES_DRIVER_POD_NAME -> name)
         case _ => None
       }
     }
   
     def getExecutorPodPrefix(conf: Map[String, String]): Option[(String, 
String)] = {
       conf.get(KUBERNETES_EXECUTOR_POD_NAME_PREFIX) match {
         case None => // skip setting if provided
           val prefix = 
KubernetesUtils.generateExecutorPodNamePrefix(conf(APP_KEY), engineRefId)
           Some(KUBERNETES_EXECUTOR_POD_NAME_PREFIX -> prefix)
         case _ => None
       }
     }
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to