mirror of https://github.com/k3s-io/k3s
Pick the PriorityClass with the lowest value of priority in case more than one global default exists
parent
930f86574f
commit
6b292822f5
|
@ -231,12 +231,17 @@ func (p *PriorityPlugin) getDefaultPriorityClass() (*scheduling.PriorityClass, e
|
|||
if err != nil {
|
||||
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 {
|
||||
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) {
|
||||
|
|
|
@ -189,6 +189,14 @@ func TestDefaultPriority(t *testing.T) {
|
|||
expectedDefaultBefore: scheduling.DefaultPriorityWhenNoDefaultClassExists,
|
||||
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",
|
||||
classesBefore: []*scheduling.PriorityClass{defaultClass1},
|
||||
|
|
Loading…
Reference in New Issue