Skip to content

Commit

Permalink
fix priority threshold by name alone
Browse files Browse the repository at this point in the history
  • Loading branch information
knelasevero committed Jul 7, 2023
1 parent ed1554d commit bd31c4f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
54 changes: 54 additions & 0 deletions pkg/descheduler/policyconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,60 @@ strategies:
},
},
},
{
description: "v1alpha1 to internal with priorityThreshould",
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: "v1alpha2 to internal",
policy: []byte(`apiVersion: "descheduler/v1alpha2"
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
18 changes: 18 additions & 0 deletions pkg/utils/priority_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package utils

// import (
// "testing"

// v1 "k8s.io/api/core/v1"
// "sigs.k8s.io/descheduler/pkg/api"
// )

// func GetPriorityValueFromPriorityThresholdTest(t *testing.T) {
// tests := []struct {
// name string
// priorityThreshold *api.PriorityThreshold
// expectedTolerations []v1.Toleration
// }{
// {},
// }
// }

0 comments on commit bd31c4f

Please sign in to comment.