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