ulysses-you commented on a change in pull request #33550:
URL: https://github.com/apache/spark/pull/33550#discussion_r680916601



##########
File path: 
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesClusterManager.scala
##########
@@ -70,8 +70,17 @@ private[spark] class KubernetesClusterManager extends 
ExternalClusterManager wit
     // If/when feature steps are executed in client mode, they should instead 
take care of this,
     // and this code should be removed.
     if (!sc.conf.contains(KUBERNETES_EXECUTOR_POD_NAME_PREFIX)) {
-      sc.conf.set(KUBERNETES_EXECUTOR_POD_NAME_PREFIX,
-        KubernetesConf.getResourceNamePrefix(sc.conf.get("spark.app.name")))
+      val podNamePrefix = 
KubernetesConf.getResourceNamePrefix(sc.conf.get("spark.app.name"))
+      if (KubernetesUtils.isValidExecutorPodNamePrefix(podNamePrefix)) {
+        sc.conf.set(KUBERNETES_EXECUTOR_POD_NAME_PREFIX, podNamePrefix)
+      } else {
+        val shortPrefix = podNamePrefix.substring(

Review comment:
       thank you @attilapiros , the idea of substring suffix is from 
`BasicExecutorFeatureStep` in this code:
   ```
     val hostname = name.substring(Math.max(0, name.length - 
KUBERNETES_DNSNAME_MAX_LENGTH))
       // Remove non-word characters from the start of the hostname
       .replaceAll("^[^\\w]+", "")
       // Replace dangerous characters in the remaining string with a safe 
alternative.
       .replaceAll("[^\\w-]+", "_")
   ```
   
   I'm OK to use the prefix if you have strong opinion, but need to change the 
code of `KubernetesConf.getResourceNamePrefix`.




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