kfaraz commented on code in PR #14282:
URL: https://github.com/apache/druid/pull/14282#discussion_r1194586315


##########
extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/common/KubernetesStringUtils.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.k8s.overlord.common;
+
+import org.apache.commons.lang3.RegExUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Locale;
+
+public class KubernetesStringUtils
+{
+  public static String parseStringToK8sLabel(String rawString)

Review Comment:
   Seems like more of a conversion operation than parsing. Maybe rename to 
`convertToK8sLabel` or something.



##########
extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/common/KubernetesStringUtils.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.k8s.overlord.common;
+
+import org.apache.commons.lang3.RegExUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Locale;
+
+public class KubernetesStringUtils

Review Comment:
   I suppose it can have other utility methods too in the future. Might as well 
just call it `K8sUtils`.



##########
extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/common/K8sTaskId.java:
##########
@@ -41,8 +38,7 @@ public K8sTaskId(String taskId)
   {
     this.originalTaskId = taskId;
     // replace all the ": - . _" to "", try to reduce the length of pod name 
and meet pod naming specifications 64 characters.

Review Comment:
   Move this comment to the javadoc of the new method.



##########
extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/common/K8sTaskId.java:
##########
@@ -41,8 +38,7 @@ public K8sTaskId(String taskId)
   {
     this.originalTaskId = taskId;
     // replace all the ": - . _" to "", try to reduce the length of pod name 
and meet pod naming specifications 64 characters.
-    this.k8sTaskId = StringUtils.left(RegExUtils.replaceAll(taskId, 
"[^a-zA-Z0-9\\\\s]", "")
-                                                .toLowerCase(Locale.ENGLISH), 
63);
+    this.k8sTaskId = KubernetesStringUtils.parseStringToK8sLabel(taskId);

Review Comment:
   I know the existing code has this too but this truncation could cause loss 
of uniqueness. Is that not a concern? I assume it should be okay if they are 
just to be used as labels.



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