mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 14:11:14 +00:00
Optimizing the implementation of the error check for PriorityClass
This commit is contained in:
@@ -162,12 +162,15 @@ func (p *PriorityPlugin) admitPod(a admission.Attributes) error {
|
||||
if !ok {
|
||||
// Now that we didn't find any system priority, try resolving by user defined priority classes.
|
||||
pc, err := p.lister.Get(pod.Spec.PriorityClassName)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get default priority class %s: %v", pod.Spec.PriorityClassName, err)
|
||||
}
|
||||
if pc == nil {
|
||||
return admission.NewForbidden(a, fmt.Errorf("no PriorityClass with name %v was found", pod.Spec.PriorityClassName))
|
||||
if errors.IsNotFound(err) {
|
||||
return admission.NewForbidden(a, fmt.Errorf("no PriorityClass with name %v was found", pod.Spec.PriorityClassName))
|
||||
}
|
||||
|
||||
return fmt.Errorf("failed to get PriorityClass with name %s: %v", pod.Spec.PriorityClassName, err)
|
||||
}
|
||||
|
||||
priority = pc.Value
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user