mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Allow absent Weight if PrioritizeVerb is empty
This commit is contained in:
parent
f07b359e5b
commit
1c60898bf5
@ -36,7 +36,7 @@ func ValidatePolicy(policy schedulerapi.Policy) error {
|
||||
|
||||
binders := 0
|
||||
for _, extender := range policy.ExtenderConfigs {
|
||||
if extender.Weight <= 0 {
|
||||
if len(extender.PrioritizeVerb) > 0 && extender.Weight <= 0 {
|
||||
validationErrors = append(validationErrors, fmt.Errorf("Priority for extender %s should have a positive weight applied to it", extender.URLPrefix))
|
||||
}
|
||||
if extender.BindVerb != "" {
|
||||
|
@ -50,18 +50,22 @@ func TestValidatePolicy(t *testing.T) {
|
||||
expected: errors.New("Priority WeightPriority should have a positive weight applied to it or it has overflown"),
|
||||
},
|
||||
{
|
||||
policy: api.Policy{ExtenderConfigs: []api.ExtenderConfig{{URLPrefix: "http://127.0.0.1:8081/extender", FilterVerb: "filter", Weight: 2}}},
|
||||
policy: api.Policy{ExtenderConfigs: []api.ExtenderConfig{{URLPrefix: "http://127.0.0.1:8081/extender", PrioritizeVerb: "prioritize", Weight: 2}}},
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
policy: api.Policy{ExtenderConfigs: []api.ExtenderConfig{{URLPrefix: "http://127.0.0.1:8081/extender", FilterVerb: "filter", Weight: -2}}},
|
||||
policy: api.Policy{ExtenderConfigs: []api.ExtenderConfig{{URLPrefix: "http://127.0.0.1:8081/extender", PrioritizeVerb: "prioritize", Weight: -2}}},
|
||||
expected: errors.New("Priority for extender http://127.0.0.1:8081/extender should have a positive weight applied to it"),
|
||||
},
|
||||
{
|
||||
policy: api.Policy{ExtenderConfigs: []api.ExtenderConfig{{URLPrefix: "http://127.0.0.1:8081/extender", FilterVerb: "filter"}}},
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
policy: api.Policy{
|
||||
ExtenderConfigs: []api.ExtenderConfig{
|
||||
{URLPrefix: "http://127.0.0.1:8081/extender", BindVerb: "bind", Weight: 2},
|
||||
{URLPrefix: "http://127.0.0.1:8082/extender", BindVerb: "bind", Weight: 2},
|
||||
{URLPrefix: "http://127.0.0.1:8081/extender", BindVerb: "bind"},
|
||||
{URLPrefix: "http://127.0.0.1:8082/extender", BindVerb: "bind"},
|
||||
}},
|
||||
expected: errors.New("Only one extender can implement bind, found 2"),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user