hehuiyuan commented on issue #24188: [SPARK-27258][K8S]Add the prefix 'spark-' for resourceNamePrefix that starts with number URL: https://github.com/apache/spark/pull/24188#issuecomment-476441377 > I think we can only update the resourceNamePrefix of service, which may be better. > > For the class of DriverServiceFeatureStep : > > ```scala > private val preferredServiceName = s"${kubernetesConf.resourceNamePrefix}$DRIVER_SVC_POSTFIX" > private val resolvedServiceName = if (preferredServiceName.length <= MAX_SERVICE_NAME_LENGTH) { > preferredServiceName > } else { > val randomServiceId = KubernetesUtils.uniqueID(clock = clock) > val shorterServiceName = s"spark-$randomServiceId$DRIVER_SVC_POSTFIX" > logWarning(s"Driver's hostname would preferably be $preferredServiceName, but this is " + > s"too long (must be <= $MAX_SERVICE_NAME_LENGTH characters). Falling back to use " + > s"$shorterServiceName as the driver service's name.") > shorterServiceName > } > ``` > > Update: > > ```scala > def isNumber(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 > && !isNumber(preferredServiceName.charAt(0))) { > preferredServiceName > } else { > val randomServiceId = KubernetesUtils.uniqueID(clock = clock) > val shorterServiceName = s"spark-$randomServiceId$DRIVER_SVC_POSTFIX" > logWarning(s"Driver's hostname would preferably be $preferredServiceName, but this is " + > s"too long (must be <= $MAX_SERVICE_NAME_LENGTH characters) " + > s"or the first character of $preferredServiceName is number which is not support." + > s" Falling back to use $shorterServiceName as the driver service's name.") > shorterServiceName > } > ``` @dongjoon-hyun @srowen Only update the resourceNamePrefix of service. Because the regular expression of Service is `[a-z]([-a-z0-9]*[a-z0-9])?)`
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
