• Kubernetes Submit Queue's avatar
    Merge pull request #54983 from chentao1596/admission-priorityclass-error-check · e991a94d
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue (batch tested with PRs 57021, 56843, 54983). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.
    
     Optimizing the implementation of the error check for PriorityClass
    
    **What this PR does / why we need it**:
    
    When i create pod(on the bottom) with not exist PriorityClass, the output will be shown as follow:
    ```
    # kubectl apply -f priorityclassname-pod.yaml 
    Error from server: error when creating "priorityclassname-pod.yaml": failed to get default priority class not-exist-priorityclassname: priorityclass.scheduling.k8s.io "not-exist-priorityclassname" not found
    ```
    
    In my eyes, "get default priority class" is not the correct description, so i changed it. The new output will be shown like this:
    ```
    # kubectl apply -f priorityclassname-pod.yaml 
    Error from server (NotFound): error when creating "priorityclassname-pod.yaml": priorityclass.scheduling.k8s.io "not-exist-priorityclassname" not found
    ```
    
    In addition, the 'pc' will never be nil when err is nil, i think this check is not neccessary, so i removed it.
    
    thank you!
    
    Pod template:
    ```
    apiVersion: v1
    kind: Pod
    metadata:
      name: priorityclassname-pod           
      labels:
        env: priorityclassname-pod    
    spec:
      containers:
      - name: was
        image: gcr.io/google_containers/busybox:v1.0
        imagePullPolicy: IfNotPresent
      priorityClassName: not-exist-priorityclassname
    ```
    e991a94d
Name
Last commit
Last update
..
admission Loading commit data...
auth Loading commit data...
scheduler Loading commit data...