Skip to content

Commit

Permalink
Merge pull request #1186 from knelasevero/fix_priority_name
Browse files Browse the repository at this point in the history
fix priority threshold by name alone
  • Loading branch information
k8s-ci-robot authored Jul 10, 2023
2 parents ed1554d + 3ff38ba commit d9b763a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 2 deletions.
75 changes: 74 additions & 1 deletion pkg/descheduler/policyconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,79 @@ strategies:
},
},
},
{
description: "v1alpha1 to internal with priorityThreshold",
policy: []byte(`apiVersion: "descheduler/v1alpha1"
kind: "DeschedulerPolicy"
strategies:
"PodLifeTime":
enabled: true
params:
podLifeTime:
maxPodLifeTimeSeconds: 5
namespaces:
include:
- "testleaderelection-a"
thresholdPriority: null
thresholdPriorityClassName: prioritym
`),
result: &api.DeschedulerPolicy{
Profiles: []api.DeschedulerProfile{
{
Name: fmt.Sprintf("strategy-%s-profile", podlifetime.PluginName),
PluginConfigs: []api.PluginConfig{
{
Name: "DefaultEvictor",
Args: &defaultevictor.DefaultEvictorArgs{
PriorityThreshold: &api.PriorityThreshold{
Value: utilpointer.Int32(0),
},
},
},
{
Name: podlifetime.PluginName,
Args: &podlifetime.PodLifeTimeArgs{
Namespaces: &api.Namespaces{
Include: []string{"testleaderelection-a"},
},
MaxPodLifeTimeSeconds: utilpointer.Uint(5),
},
},
},
Plugins: api.Plugins{
Filter: api.PluginSet{
Enabled: []string{defaultevictor.PluginName},
},
PreEvictionFilter: api.PluginSet{
Enabled: []string{defaultevictor.PluginName},
},
Deschedule: api.PluginSet{
Enabled: []string{podlifetime.PluginName},
},
},
},
},
},
},
{
description: "v1alpha1 to internal with priorityThreshold value and name should return error",
policy: []byte(`apiVersion: "descheduler/v1alpha1"
kind: "DeschedulerPolicy"
strategies:
"PodLifeTime":
enabled: true
params:
podLifeTime:
maxPodLifeTimeSeconds: 5
namespaces:
include:
- "testleaderelection-a"
thresholdPriority: 222
thresholdPriorityClassName: prioritym
`),
result: nil,
err: fmt.Errorf("failed decoding descheduler's policy config \"filename\": priority threshold misconfigured for plugin PodLifeTime"),
},
{
description: "v1alpha2 to internal",
policy: []byte(`apiVersion: "descheduler/v1alpha2"
Expand Down Expand Up @@ -930,7 +1003,7 @@ profiles:
if err != nil {
if tc.err == nil {
t.Errorf("unexpected error: %s.", err.Error())
} else {
} else if err.Error() != tc.err.Error() {
t.Errorf("unexpected error: %s. Was expecting %s", err.Error(), tc.err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/framework/plugins/defaultevictor/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
func ValidateDefaultEvictorArgs(obj runtime.Object) error {
args := obj.(*DefaultEvictorArgs)

if args.PriorityThreshold != nil && len(args.PriorityThreshold.Name) > 0 {
if args.PriorityThreshold != nil && args.PriorityThreshold.Value != nil && len(args.PriorityThreshold.Name) > 0 {
return fmt.Errorf("priority threshold misconfigured, only one of priorityThreshold fields can be set, got %v", args)
}

Expand Down

0 comments on commit d9b763a

Please sign in to comment.