You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2020/03/27 12:19:16 UTC

[GitHub] [incubator-yunikorn-k8shim] wilfred-s commented on a change in pull request #88: [YUNIKORN-54] admission-controller should keep generated ID tight

wilfred-s commented on a change in pull request #88: [YUNIKORN-54] admission-controller should keep generated ID tight
URL: https://github.com/apache/incubator-yunikorn-k8shim/pull/88#discussion_r399224232
 
 

 ##########
 File path: pkg/plugin/admissioncontrollers/webhook/admission_controller.go
 ##########
 @@ -138,25 +138,7 @@ func updateLabels(pod *v1.Pod, patch []patchOperation) []patchOperation {
 
 	if _, ok := existingLabels[common.SparkLabelAppID]; !ok {
 		if _, ok := existingLabels[common.LabelApplicationID]; !ok {
-			// if app id not exist, generate one
-			// the generated ID is using [PodNamespace]_[PodName]_[Timestamp] naming convention.
-			// some admission controllers have strict checks of the length/format of each labels,
-			// this convention keeps the name tidy and short.
-			podNamespace := "default"
-			if pod.Namespace != "" {
-				podNamespace = pod.Namespace
-			}
-
-			// pod's name can be generated, if name is not explicitly specified
-			// look for generateName instead
-			podName := "unknown"
-			if pod.Name != "" {
-				podName = pod.Name
-			} else if pod.GenerateName != "" {
-				podName = pod.GenerateName
-			}
-
-			generatedID := fmt.Sprintf("%s_%s_%d", podNamespace, podName, time.Now().Unix())
+			generatedID := fmt.Sprintf("__app_%d", time.Now().UnixNano())
 
 Review comment:
   Why throw out all the info we have and then try to substitute it with some other info?
   If we have the detail we should use it. The change will limit the label to a maximum of 64 char.
   
   If the build up `podName` turns out to be empty we should substitute at that point instead of the  generic rule.

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