You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/08/22 02:56:58 UTC

[GitHub] [pulsar] freeznet commented on a change in pull request #4996: [k8s] convert to valid pod name part with k8s function runtime

freeznet commented on a change in pull request #4996: [k8s] convert to valid pod name part with k8s function runtime
URL: https://github.com/apache/pulsar/pull/4996#discussion_r316479121
 
 

 ##########
 File path: pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java
 ##########
 @@ -1011,8 +1011,12 @@ private static String createJobName(Function.FunctionDetails functionDetails) {
                 functionDetails.getName());
     }
 
+    private static String toValidPodName(String ori) {
+        return ori.toLowerCase().replaceAll("[^a-z0-9]", "-");
+    }
+
     private static String createJobName(String tenant, String namespace, String functionName) {
-        return "pf-" + tenant + "-" + namespace + "-" + functionName;
+        return "pf-" + toValidPodName(tenant) + "-" + toValidPodName(namespace) + "-" + toValidPodName(functionName);
 
 Review comment:
   @cckellogg The intension of this PR is to solve problem if `functionName` not meet the `VALID_POD_NAME_REGEX` will cause broker pod panic. Once all brokers are assigned to this function, the broker cluster will down. 
   - For backwards compatibility, i do forgot to consider in this PR, but the backwards compatibility is based on those `functionName` already match the `VALID_POD_NAME_REGEX`. Thus, we can change the logic here to:
     - test if `"pf-" + tenant + "-" + namespace + "-" + functionName` returns valid pod name which matches `VALID_POD_NAME_REGEX`.
     - if match, we use it.
     - if not match, we use `toValidPodName` in this PR to generate a valid pod name with `toLowerCase()` and mapping non-valid chars to "-".
   
   - For "." problem, i can change the regex part to not map "." to "-". 
   ```
       private static String toValidPodName(String ori) {
           return ori.toLowerCase().replaceAll("[^a-z0-9-\.]", "-");
       }
   ```
   
   - For naming collisions, how about to append a short hash to the pod name?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services