mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +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
|
binders := 0
|
||||||
for _, extender := range policy.ExtenderConfigs {
|
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))
|
validationErrors = append(validationErrors, fmt.Errorf("Priority for extender %s should have a positive weight applied to it", extender.URLPrefix))
|
||||||
}
|
}
|
||||||
if extender.BindVerb != "" {
|
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"),
|
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,
|
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"),
|
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{
|
policy: api.Policy{
|
||||||
ExtenderConfigs: []api.ExtenderConfig{
|
ExtenderConfigs: []api.ExtenderConfig{
|
||||||
{URLPrefix: "http://127.0.0.1:8081/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", Weight: 2},
|
{URLPrefix: "http://127.0.0.1:8082/extender", BindVerb: "bind"},
|
||||||
}},
|
}},
|
||||||
expected: errors.New("Only one extender can implement bind, found 2"),
|
expected: errors.New("Only one extender can implement bind, found 2"),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user