Yikun commented on a change in pull request #35943:
URL: https://github.com/apache/spark/pull/35943#discussion_r832802242



##########
File path: 
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
##########
@@ -270,7 +271,7 @@ private[spark] object KubernetesConf {
         .replaceAll("-+", "-"),
       "",
       KUBERNETES_DNSNAME_MAX_LENGTH
-    )
+    ).stripPrefix("-").stripSuffix("-")

Review comment:
       Note for my self or others: k8s label allow `dashes (-), underscores 
(_), dots (.)`, we alread replaced `underscores (_)`, `dots (.)` by `dashes 
(-)` before, so strip "-" prefix/suffix is enough in here.
   
   Below tests are also passed:
   ```
   assert(KubernetesConf.getAppNameLabel(".hello.") === "hello")
   assert(KubernetesConf.getAppNameLabel("_hello_") === "hello")
   ```




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to