Skip to content

Commit 1aef8b7

Browse files
[SPARK-40869][K8S] Resource name prefix should not start with a hyphen
### What changes were proposed in this pull request? Strip leading - from resource name prefix ### Why are the changes needed? leading - are not allowed for resource name prefix (especially spark.kubernetes.executor.podNamePrefix) ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Unit test Closes #38331 from tobiasstadler/fix-SPARK-40869. Lead-authored-by: Tobias Stadler <[email protected]> Co-authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 7f3b598) Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent b9d22ac commit 1aef8b7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ private[spark] object KubernetesConf {
233233
.toLowerCase(Locale.ROOT)
234234
.replaceAll("[^a-z0-9\\-]", "-")
235235
.replaceAll("-+", "-")
236+
.replaceAll("^-", "")
236237
}
237238

238239
/**

resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,8 @@ class KubernetesConfSuite extends SparkFunSuite {
178178
assert(driverConf.asInstanceOf[KubernetesConf].appId === KubernetesTestConf.APP_ID)
179179
assert(execConf.asInstanceOf[KubernetesConf].appId === KubernetesTestConf.APP_ID)
180180
}
181+
182+
test("SPARK-40869: Resource name prefix should not start with a hyphen") {
183+
assert(KubernetesConf.getResourceNamePrefix("_hello_").startsWith("hello"))
184+
}
181185
}

0 commit comments

Comments
 (0)