chenyulin0719 opened a new pull request, #900:
URL: https://github.com/apache/yunikorn-k8shim/pull/900

   ### What is this PR for?
   - Throw below warning in scheduler pod if pod has inconsistent metadata
   ```
   2024-08-23T10:44:15.940Z     WARN    shim.cache.task cache/task.go:545       
The task has conflicting metadata will be rejected after version 1.7.0. 
{"appID": "application-sleep-00002", "podName": "pod-with-inconsistent-queue", 
"error": "pod has inconsistent queue name in labels and annotations. 
inconsistent values: root.sandbox, root.sandbox-annotation"}
   
   2024-08-23T10:44:15.940Z     WARN    shim.cache.task cache/task.go:539       
The task has conflicting metadata will be rejected after version 1.7.0. 
{"appID": "application-sleep-00001-annotation", "podName": 
"pod-with-inconsistent-app-id", "error": "pod has inconsistent application ID 
in labels and annotations. inconsistent values: application-sleep-00001, 
application-sleep-00001-annotation"}
   
   ```
   
   - Extract the logic in sanityCheckBeforeScheduling to new method 
checkPodPVCs()
   
   ### What type of PR is it?
   * [x] - Feature
   
   ### Todos
   * Throw warning in AdmissionController if a pod has inconsistent metadata
   * Update Doc 
https://yunikorn.apache.org/docs/next/user_guide/labels_and_annotations_in_yunikorn
   
   ### What is the Jira issue?
   https://issues.apache.org/jira/browse/YUNIKORN-2810
   
   ### How should this be tested?
   - make test
   - Or build k8shim and create pods with below yaml:
   
   ```
   apiVersion: v1
   kind: ConfigMap
   metadata:
     name: yunikorn-configs
     namespace: yunikorn
   data:
     queues.yaml: |
       partitions:
         - name: default
           queues:
             - name: root
               submitacl: '*'
               queues:
                 - name: sandbox
           placementrules:
             - name: provided
               create: true
   
   ---
   
   
   
   apiVersion: v1
   kind: Pod
   metadata:
     labels:
       app: sleep
       yunikorn.apache.org/app-id: "application-sleep-00002"
       queue: "root.sandbox"
     annotations:
       yunikorn.apache.org/queue: "root.sandbox-annotation"
     name: pod-with-inconsistent-queue
   spec:
     schedulerName: yunikorn
     restartPolicy: Never
     containers:
       - name: sleep-6000s
         image: "alpine:latest"
         command: ["sleep", "6000"]
         resources:
           requests:
             cpu: "100m"
             memory: "500M"
   
   ---
   
   apiVersion: v1
   kind: Pod
   metadata:
     labels:
       app: sleep
       applicationId: "application-sleep-00001"
     annotations:
       yunikorn.apache.org/app-id: "application-sleep-00001-annotation"
     name: pod-with-inconsistent-app-id
   spec:
     schedulerName: yunikorn
     restartPolicy: Never
     containers:
       - name: sleep-6000s
         image: "alpine:latest"
         command: ["sleep", "6000"]
         resources:
           requests:
             cpu: "100m"
             memory: "500M"
   
   ```
   
   Run below command to check sheduler log. 
   ```kubectl logs -l component=yunikorn-scheduler -n yunikorn > 
yunikorn-scheduler-logs.txt```
   
   ### Screenshots (if appropriate)
   
   
   
   ### Questions:
   NA
   


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