• 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
..
admit Loading commit data...
alwayspullimages Loading commit data...
antiaffinity Loading commit data...
defaulttolerationseconds Loading commit data...
deny Loading commit data...
eventratelimit Loading commit data...
exec Loading commit data...
extendedresourcetoleration Loading commit data...
gc Loading commit data...
imagepolicy Loading commit data...
initialresources Loading commit data...
limitranger Loading commit data...
namespace Loading commit data...
noderestriction Loading commit data...
persistentvolume Loading commit data...
persistentvolumeclaim/pvcprotection Loading commit data...
podnodeselector Loading commit data...
podpreset Loading commit data...
podtolerationrestriction Loading commit data...
priority Loading commit data...
resourcequota Loading commit data...
security Loading commit data...
securitycontext/scdeny Loading commit data...
serviceaccount Loading commit data...
storageclass/setdefault Loading commit data...
OWNERS Loading commit data...