ruanwenjun commented on code in PR #53307:
URL: https://github.com/apache/spark/pull/53307#discussion_r2608851973


##########
resource-managers/kubernetes/core/volcano/src/main/scala/org/apache/spark/deploy/k8s/features/VolcanoFeatureStep.scala:
##########
@@ -59,13 +66,42 @@ private[spark] class VolcanoFeatureStep extends 
KubernetesDriverCustomFeatureCon
     if (spec == null) spec = new PodGroupSpec
     pg.setSpec(spec)
 
+    logDebug(s"Volcano PodGroup configuration: $pg")
     Seq(pg)
   }
 
+  private def getPodGroupConfigByTemplateFile(
+      volcanoClient: DefaultVolcanoClient): Option[PodGroup] = {
+    kubernetesConf.getOption(POD_GROUP_TEMPLATE_FILE_KEY).map { templateFile =>
+      logDebug("Loading Volcano PodGroup configuration from template file")
+      volcanoClient.podGroups.load(templateFile).item
+    }
+  }
+
+  private def getPodGroupByTemplateJson(volcanoClient: DefaultVolcanoClient): 
Option[PodGroup] = {
+    kubernetesConf.getOption(POD_GROUP_TEMPLATE_JSON_KEY).map { templateJson =>
+      logDebug("Loading Volcano PodGroup configuration from template json")
+      try {
+        val templateYaml = new ObjectMapper()
+          .writerWithDefaultPrettyPrinter()
+          .writeValueAsString(new ObjectMapper(new 
YAMLFactory()).readTree(templateJson))
+        volcanoClient
+          .podGroups()
+          .load(new java.io.ByteArrayInputStream(templateYaml.getBytes()))
+          .item()
+      } catch {
+        case e: Exception =>
+          throw new SparkException(
+            f"The ${POD_GROUP_TEMPLATE_JSON_KEY} provided is not validated",
+            e)
+      }
+    }
+  }
+
   override def configurePod(pod: SparkPod): SparkPod = {
     val k8sPodBuilder = new PodBuilder(pod.pod)
       .editMetadata()
-        .addToAnnotations(POD_GROUP_ANNOTATION, podGroupName)
+      .addToAnnotations(POD_GROUP_ANNOTATION, podGroupName)

Review Comment:
   Done



##########
resource-managers/kubernetes/core/volcano/src/test/scala/org/apache/spark/deploy/k8s/features/VolcanoFeatureStepSuite.scala:
##########
@@ -34,7 +34,8 @@ class VolcanoFeatureStepSuite extends SparkFunSuite {
 
     val annotations = configuredPod.pod.getMetadata.getAnnotations
 
-    assert(annotations.get("scheduling.k8s.io/group-name") === 
s"${kubernetesConf.appId}-podgroup")
+    assert(
+      annotations.get("scheduling.k8s.io/group-name") === 
s"${kubernetesConf.appId}-podgroup")

Review Comment:
   Done



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