You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/10/04 23:46:30 UTC

[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29934: [SPARK-32067][K8S] Give pod template configmap a unique name

dongjoon-hyun commented on a change in pull request #29934:
URL: https://github.com/apache/spark/pull/29934#discussion_r499301593



##########
File path: resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/PodTemplateConfigMapStep.scala
##########
@@ -22,23 +22,39 @@ import java.nio.charset.StandardCharsets
 import com.google.common.io.Files
 import io.fabric8.kubernetes.api.model.{ConfigMapBuilder, ContainerBuilder, HasMetadata, PodBuilder}
 
-import org.apache.spark.deploy.k8s.{KubernetesConf, SparkPod}
+import org.apache.spark.deploy.k8s.{KubernetesConf, KubernetesUtils, SparkPod}
 import org.apache.spark.deploy.k8s.Config._
 import org.apache.spark.deploy.k8s.Constants._
+import org.apache.spark.internal.Logging
+import org.apache.spark.util.{Clock, SystemClock}
 
-private[spark] class PodTemplateConfigMapStep(conf: KubernetesConf)
-  extends KubernetesFeatureConfigStep {
+private[spark] class PodTemplateConfigMapStep
+(conf: KubernetesConf, clock: Clock = new SystemClock())
+  extends KubernetesFeatureConfigStep with Logging {
 
   private val hasTemplate = conf.contains(KUBERNETES_EXECUTOR_PODTEMPLATE_FILE)
 
+  private val preferredConfigmapName = s"${conf.resourceNamePrefix}-$POD_TEMPLATE_CONFIGMAP"
+  private val resolvedConfigmapName =
+    if (preferredConfigmapName.length <= KUBERNETES_MAX_NAME_LENGTH) {
+    preferredConfigmapName
+  } else {
+    val randomServiceId = KubernetesUtils.uniqueID(clock = clock)

Review comment:
       `randomServiceId` -> `randomId`?




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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org