Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-27258][K8S]Deal with the k8s resource names that don't match their own regular expression #24219

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
erikerlandson marked this conversation as resolved.
Show resolved Hide resolved
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))) {
erikerlandson marked this conversation as resolved.
Show resolved Hide resolved
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.")
s"too long (must be <= $MAX_SERVICE_NAME_LENGTH characters) " +
s"or the first character of $preferredServiceName is digit which is not support." +
s" Falling back to use $shorterServiceName as the driver service's name.")
shorterServiceName
}

Expand Down