craigcondit commented on code in PR #900:
URL: https://github.com/apache/yunikorn-k8shim/pull/900#discussion_r1735140143


##########
pkg/cache/task.go:
##########
@@ -533,6 +533,25 @@ func (task *Task) releaseAllocation() {
 // this reduces the scheduling overhead by blocking such
 // request away from the core scheduler.
 func (task *Task) sanityCheckBeforeScheduling() error {
+       // After version 1.7.0, we should reject the task whose pod is unbound 
and has conflicting metadata.
+       if !utils.PodAlreadyBound(task.pod) {
+               if err := utils.CheckAppIdInPod(task.pod); err != nil {
+                       log.Log(log.ShimCacheTask).Warn("The task has 
conflicting metadata will be rejected after version 1.7.0.",
+                               zap.String("appID", task.applicationID),
+                               zap.String("podName", task.pod.Name),
+                               zap.String("error", err.Error()))
+               }
+               if err := utils.CheckQueueNameInPod(task.pod); err != nil {
+                       log.Log(log.ShimCacheTask).Warn("The task has 
conflicting metadata will be rejected after version 1.7.0.",

Review Comment:
   The message should probably be a little different:
   
   "Pod has inconsistent queue metadata and may be rejected in a future 
YuniKorn release"



##########
pkg/cache/task.go:
##########
@@ -533,6 +533,25 @@ func (task *Task) releaseAllocation() {
 // this reduces the scheduling overhead by blocking such
 // request away from the core scheduler.
 func (task *Task) sanityCheckBeforeScheduling() error {
+       // After version 1.7.0, we should reject the task whose pod is unbound 
and has conflicting metadata.
+       if !utils.PodAlreadyBound(task.pod) {
+               if err := utils.CheckAppIdInPod(task.pod); err != nil {
+                       log.Log(log.ShimCacheTask).Warn("The task has 
conflicting metadata will be rejected after version 1.7.0.",

Review Comment:
   The message should probably be a little different:
   
   "Pod has inconsistent application metadata and may be rejected in a future 
YuniKorn release"



##########
pkg/cache/task.go:
##########
@@ -533,6 +533,25 @@ func (task *Task) releaseAllocation() {
 // this reduces the scheduling overhead by blocking such
 // request away from the core scheduler.
 func (task *Task) sanityCheckBeforeScheduling() error {
+       // After version 1.7.0, we should reject the task whose pod is unbound 
and has conflicting metadata.
+       if !utils.PodAlreadyBound(task.pod) {
+               if err := utils.CheckAppIdInPod(task.pod); err != nil {
+                       log.Log(log.ShimCacheTask).Warn("The task has 
conflicting metadata will be rejected after version 1.7.0.",
+                               zap.String("appID", task.applicationID),
+                               zap.String("podName", task.pod.Name),
+                               zap.String("error", err.Error()))
+               }
+               if err := utils.CheckQueueNameInPod(task.pod); err != nil {
+                       log.Log(log.ShimCacheTask).Warn("The task has 
conflicting metadata will be rejected after version 1.7.0.",
+                               zap.String("appID", task.applicationID),
+                               zap.String("podName", task.pod.Name),
+                               zap.String("error", err.Error()))
+               }
+       }
+       return task.checkPodPVCs()

Review Comment:
   In addition to the logged messages, we should also send pod events to inform 
the pod submitter of the potential issue.



##########
pkg/common/utils/utils.go:
##########
@@ -213,6 +213,51 @@ func GetApplicationIDFromPod(pod *v1.Pod) string {
        return GenerateApplicationID(pod.Namespace, 
conf.GetSchedulerConf().GenerateUniqueAppIds, string(pod.UID))
 }
 
+func CheckAppIdInPod(pod *v1.Pod) error {
+       if err := ValidatePodLabelAnnotation(pod, constants.AppIdLabelKeys, 
constants.AppIdAnnotationKeys); err != nil {
+               return fmt.Errorf("pod has inconsistent application ID in 
labels and annotations. %w", err)
+       }
+       return nil
+}
+
+func CheckQueueNameInPod(pod *v1.Pod) error {
+       if err := ValidatePodLabelAnnotation(pod, constants.QueueLabelKeys, 
constants.QueueAnnotationKeys); err != nil {
+               return fmt.Errorf("pod has inconsistent queue name in labels 
and annotations. %w", err)
+       }
+       return nil

Review Comment:
   I think we need the error messages to indicate *which* metadata sources were 
inconsistent. For example:
   
   "pod has inconsistent application metadata: label applicationID: foo != 
annotation yunikorn.org/app-id: bar"
   
   Dynamically populate this based on which elements were in conflict.



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

Reply via email to