This is an automated email from the ASF dual-hosted git repository. dongjoon pushed a commit to branch branch-3.3 in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.3 by this push: new ff23498b42c [SPARK-40869][K8S] Resource name prefix should not start with a hyphen ff23498b42c is described below commit ff23498b42c6d45747bd1b619c60bb0c2d2da3bf Author: Tobias Stadler <ts.stad...@gmx.de> AuthorDate: Thu Nov 3 10:34:04 2022 -0700 [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 <ts.stad...@gmx.de> Co-authored-by: Dongjoon Hyun <dongj...@apache.org> Signed-off-by: Dongjoon Hyun <dongj...@apache.org> (cherry picked from commit 7f3b5987de1f79434a861408e6c8bf55c5598031) Signed-off-by: Dongjoon Hyun <dongj...@apache.org> --- .../src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala | 1 + .../test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala index 510609537cf..60ded7cbd0c 100644 --- a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala +++ b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala @@ -256,6 +256,7 @@ private[spark] object KubernetesConf { .toLowerCase(Locale.ROOT) .replaceAll("[^a-z0-9\\-]", "-") .replaceAll("-+", "-") + .replaceAll("^-", "") } def getAppNameLabel(appName: String): String = { diff --git a/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala b/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala index d33d7924910..95ef27c2a18 100644 --- a/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala +++ b/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala @@ -250,4 +250,8 @@ class KubernetesConfSuite extends SparkFunSuite { assert(KubernetesConf.getAppNameLabel("a" * 62 + "-aaa") === "a" * 62) assert(KubernetesConf.getAppNameLabel("-" + "a" * 63) === "a" * 62) } + + test("SPARK-40869: Resource name prefix should not start with a hyphen") { + assert(KubernetesConf.getResourceNamePrefix("_hello_").startsWith("hello")) + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org