mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 21:31:18 +01:00
add v1alpha2 registry based conversion (#1006)
* add v1alpha2 registry based conversion * test defaults, set our 1st explicit default * fix typos and dates * move pluginregistry to its own dir * remove unused v1alpha2.Namespace type * move migration code folders, remove switch * validate internalPolicy a single time * remove structured logs * simplify return * check for nil methods * properly check before adding default evictor * add TODO comment * bump copyright year
This commit is contained in:
committed by
GitHub
parent
861c6325f3
commit
137f3b20dc
@@ -23,28 +23,30 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_LowNodeUtilizationArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_LowNodeUtilizationArgs(obj *LowNodeUtilizationArgs) {
|
||||
if !obj.UseDeviationThresholds {
|
||||
obj.UseDeviationThresholds = false
|
||||
func SetDefaults_LowNodeUtilizationArgs(obj runtime.Object) {
|
||||
args := obj.(*LowNodeUtilizationArgs)
|
||||
if !args.UseDeviationThresholds {
|
||||
args.UseDeviationThresholds = false
|
||||
}
|
||||
if obj.Thresholds == nil {
|
||||
obj.Thresholds = nil
|
||||
if args.Thresholds == nil {
|
||||
args.Thresholds = nil
|
||||
}
|
||||
if obj.TargetThresholds == nil {
|
||||
obj.TargetThresholds = nil
|
||||
if args.TargetThresholds == nil {
|
||||
args.TargetThresholds = nil
|
||||
}
|
||||
if obj.NumberOfNodes == 0 {
|
||||
obj.NumberOfNodes = 0
|
||||
if args.NumberOfNodes == 0 {
|
||||
args.NumberOfNodes = 0
|
||||
}
|
||||
}
|
||||
|
||||
// SetDefaults_HighNodeUtilizationArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_HighNodeUtilizationArgs(obj *HighNodeUtilizationArgs) {
|
||||
if obj.Thresholds == nil {
|
||||
obj.Thresholds = nil
|
||||
func SetDefaults_HighNodeUtilizationArgs(obj runtime.Object) {
|
||||
args := obj.(*HighNodeUtilizationArgs)
|
||||
if args.Thresholds == nil {
|
||||
args.Thresholds = nil
|
||||
}
|
||||
if obj.NumberOfNodes == 0 {
|
||||
obj.NumberOfNodes = 0
|
||||
if args.NumberOfNodes == 0 {
|
||||
args.NumberOfNodes = 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,12 @@ package nodeutilization
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"sigs.k8s.io/descheduler/pkg/api"
|
||||
)
|
||||
|
||||
func ValidateHighNodeUtilizationArgs(args *HighNodeUtilizationArgs) error {
|
||||
func ValidateHighNodeUtilizationArgs(obj runtime.Object) error {
|
||||
args := obj.(*HighNodeUtilizationArgs)
|
||||
// only exclude can be set, or not at all
|
||||
if args.EvictableNamespaces != nil && len(args.EvictableNamespaces.Include) > 0 {
|
||||
return fmt.Errorf("only Exclude namespaces can be set, inclusion is not supported")
|
||||
@@ -32,7 +34,8 @@ func ValidateHighNodeUtilizationArgs(args *HighNodeUtilizationArgs) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateLowNodeUtilizationArgs(args *LowNodeUtilizationArgs) error {
|
||||
func ValidateLowNodeUtilizationArgs(obj runtime.Object) error {
|
||||
args := obj.(*LowNodeUtilizationArgs)
|
||||
// only exclude can be set, or not at all
|
||||
if args.EvictableNamespaces != nil && len(args.EvictableNamespaces.Include) > 0 {
|
||||
return fmt.Errorf("only Exclude namespaces can be set, inclusion is not supported")
|
||||
|
||||
@@ -29,15 +29,5 @@ import (
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
scheme.AddTypeDefaultingFunc(&HighNodeUtilizationArgs{}, func(obj interface{}) { SetObjectDefaults_HighNodeUtilizationArgs(obj.(*HighNodeUtilizationArgs)) })
|
||||
scheme.AddTypeDefaultingFunc(&LowNodeUtilizationArgs{}, func(obj interface{}) { SetObjectDefaults_LowNodeUtilizationArgs(obj.(*LowNodeUtilizationArgs)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_HighNodeUtilizationArgs(in *HighNodeUtilizationArgs) {
|
||||
SetDefaults_HighNodeUtilizationArgs(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_LowNodeUtilizationArgs(in *LowNodeUtilizationArgs) {
|
||||
SetDefaults_LowNodeUtilizationArgs(in)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user