mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Pick the PriorityClass with the lowest value of priority in case more than one global default exists
This commit is contained in:
parent
930f86574f
commit
6b292822f5
@ -231,12 +231,17 @@ func (p *PriorityPlugin) getDefaultPriorityClass() (*scheduling.PriorityClass, e
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// In case more than one global default priority class is added as a result of a race condition,
|
||||||
|
// we pick the one with the lowest priority value.
|
||||||
|
var defaultPC *scheduling.PriorityClass
|
||||||
for _, pci := range list {
|
for _, pci := range list {
|
||||||
if pci.GlobalDefault {
|
if pci.GlobalDefault {
|
||||||
return pci, nil
|
if defaultPC == nil || defaultPC.Value > pci.Value {
|
||||||
|
defaultPC = pci
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, nil
|
}
|
||||||
|
return defaultPC, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PriorityPlugin) getDefaultPriority() (int32, error) {
|
func (p *PriorityPlugin) getDefaultPriority() (int32, error) {
|
||||||
|
@ -189,6 +189,14 @@ func TestDefaultPriority(t *testing.T) {
|
|||||||
expectedDefaultBefore: scheduling.DefaultPriorityWhenNoDefaultClassExists,
|
expectedDefaultBefore: scheduling.DefaultPriorityWhenNoDefaultClassExists,
|
||||||
expectedDefaultAfter: defaultClass1.Value,
|
expectedDefaultAfter: defaultClass1.Value,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "multiple default classes resolves to the minimum value among them",
|
||||||
|
classesBefore: []*scheduling.PriorityClass{defaultClass1, defaultClass2},
|
||||||
|
classesAfter: []*scheduling.PriorityClass{defaultClass2},
|
||||||
|
attributes: admission.NewAttributesRecord(nil, nil, pcKind, "", defaultClass1.Name, pcResource, "", admission.Delete, nil),
|
||||||
|
expectedDefaultBefore: defaultClass1.Value,
|
||||||
|
expectedDefaultAfter: defaultClass2.Value,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "delete default priority class",
|
name: "delete default priority class",
|
||||||
classesBefore: []*scheduling.PriorityClass{defaultClass1},
|
classesBefore: []*scheduling.PriorityClass{defaultClass1},
|
||||||
|
Loading…
Reference in New Issue
Block a user