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 2019/03/26 12:57:01 UTC

[GitHub] [spark] hehuiyuan commented on a change in pull request #24219: [SPARK-27258][K8S] If the first character of Service's name is not a-z, which does not match regular expression ^[a-z]([-a-z0-9]*[a-z0-9])?), this situation needs to be dealt

hehuiyuan commented on a change in pull request #24219: [SPARK-27258][K8S] If the first character of  Service's name is not a-z,which  does not match regular expression ^[a-z]([-a-z0-9]*[a-z0-9])?),this situation needs to be dealt
URL: https://github.com/apache/spark/pull/24219#discussion_r269085830
 
 

 ##########
 File path: resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/DriverServiceFeatureStep.scala
 ##########
 @@ -38,15 +38,21 @@ private[spark] class DriverServiceFeatureStep(
     s"$DRIVER_HOST_KEY is not supported in Kubernetes mode, as the driver's hostname will be " +
       "managed via a Kubernetes service.")
 
+  def isDigit(char: Char) : Boolean = {
+    char >= '0' && char <= '9'
+  }
+
   private val preferredServiceName = s"${kubernetesConf.resourceNamePrefix}$DRIVER_SVC_POSTFIX"
-  private val resolvedServiceName = if (preferredServiceName.length <= MAX_SERVICE_NAME_LENGTH) {
+  private val resolvedServiceName = if (preferredServiceName.length <= MAX_SERVICE_NAME_LENGTH
+    && !isDigit(preferredServiceName.charAt(0))) {
 
 Review comment:
   I say digit,  because resourceNamePrefix  that has been processed and contains three kinds :
   (1)0-9
   (2)a-z
   (3)- 
   
   
   ```
     def getResourceNamePrefix(appName: String): String = {
       val id = KubernetesUtils.uniqueID()
       s"$appName-$id"
         .trim
         .toLowerCase(Locale.ROOT)
         .replaceAll("\\s+", "-")
         .replaceAll("\\.", "-")
         .replaceAll("[^a-z0-9\\-]", "")
         .replaceAll("-+", "-")
     }
   ```

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


With regards,
Apache Git Services

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