You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2022/11/03 17:34:19 UTC

[spark] branch master updated: [SPARK-40869][K8S] Resource name prefix should not start with a hyphen

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 7f3b5987de1 [SPARK-40869][K8S] Resource name prefix should not start with a hyphen
7f3b5987de1 is described below

commit 7f3b5987de1f79434a861408e6c8bf55c5598031
Author: Tobias Stadler <ts...@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...@gmx.de>
    Co-authored-by: Dongjoon Hyun <do...@apache.org>
    Signed-off-by: Dongjoon Hyun <do...@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-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org