1
0
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:
Lucas Severo Alves
2023-01-17 17:10:34 +01:00
committed by GitHub
parent 861c6325f3
commit 137f3b20dc
50 changed files with 1867 additions and 492 deletions

View File

@@ -23,29 +23,30 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
// SetDefaults_DefaultEvictorArgs
// TODO: the final default values would be discussed in community
func SetDefaults_DefaultEvictorArgs(obj *DefaultEvictorArgs) {
if obj.NodeSelector == "" {
obj.NodeSelector = ""
func SetDefaults_DefaultEvictorArgs(obj runtime.Object) {
args := obj.(*DefaultEvictorArgs)
if args.NodeSelector == "" {
args.NodeSelector = ""
}
if !obj.EvictLocalStoragePods {
obj.EvictSystemCriticalPods = false
if !args.EvictLocalStoragePods {
args.EvictSystemCriticalPods = false
}
if !obj.EvictSystemCriticalPods {
obj.EvictSystemCriticalPods = false
if !args.EvictSystemCriticalPods {
args.EvictSystemCriticalPods = false
}
if !obj.IgnorePvcPods {
obj.IgnorePvcPods = false
if !args.IgnorePvcPods {
args.IgnorePvcPods = false
}
if !obj.EvictFailedBarePods {
obj.EvictFailedBarePods = false
if !args.EvictFailedBarePods {
args.EvictFailedBarePods = false
}
if obj.LabelSelector == nil {
obj.LabelSelector = nil
if args.LabelSelector == nil {
args.LabelSelector = nil
}
if obj.PriorityThreshold == nil {
obj.PriorityThreshold = nil
if args.PriorityThreshold == nil {
args.PriorityThreshold = nil
}
if !obj.NodeFit {
obj.NodeFit = false
if !args.NodeFit {
args.NodeFit = false
}
}

View File

@@ -0,0 +1,30 @@
/*
Copyright 2022 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package defaultevictor
import (
"fmt"
"k8s.io/apimachinery/pkg/runtime"
)
func ValidateDefaultEvictorArgs(obj runtime.Object) error {
args := obj.(*DefaultEvictorArgs)
if args.PriorityThreshold != nil && len(args.PriorityThreshold.Name) > 0 {
return fmt.Errorf("priority threshold misconfigured, only one of priorityThreshold fields can be set, got %v", args)
}
return nil
}

View File

@@ -29,10 +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(&DefaultEvictorArgs{}, func(obj interface{}) { SetObjectDefaults_DefaultEvictorArgs(obj.(*DefaultEvictorArgs)) })
return nil
}
func SetObjectDefaults_DefaultEvictorArgs(in *DefaultEvictorArgs) {
SetDefaults_DefaultEvictorArgs(in)
}