mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 13:29:11 +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,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
|
||||
}
|
||||
}
|
||||
|
||||
30
pkg/framework/plugins/defaultevictor/validation.go
Normal file
30
pkg/framework/plugins/defaultevictor/validation.go
Normal 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
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
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 pluginbuilder
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/klog/v2"
|
||||
"sigs.k8s.io/descheduler/pkg/framework"
|
||||
)
|
||||
|
||||
var PluginRegistry Registry
|
||||
|
||||
type PluginBuilderAndArgsInstance struct {
|
||||
PluginBuilder PluginBuilder
|
||||
// Just an example instance of this PluginArg so we can avoid having
|
||||
// to deal with reflect Types
|
||||
PluginArgInstance runtime.Object
|
||||
}
|
||||
|
||||
type PluginBuilder = func(args runtime.Object, handle framework.Handle) (framework.Plugin, error)
|
||||
|
||||
type Registry = map[string]PluginBuilderAndArgsInstance
|
||||
|
||||
func NewRegistry() Registry {
|
||||
return Registry{}
|
||||
}
|
||||
|
||||
func Register(name string, builderFunc PluginBuilder, exampleArg runtime.Object, registry Registry) {
|
||||
if _, ok := registry[name]; ok {
|
||||
klog.V(10).InfoS("Plugin already registered", "plugin", name)
|
||||
} else {
|
||||
registry[name] = PluginBuilderAndArgsInstance{
|
||||
PluginBuilder: builderFunc,
|
||||
PluginArgInstance: exampleArg,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,17 +23,18 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_PodLifeTimeArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_PodLifeTimeArgs(obj *PodLifeTimeArgs) {
|
||||
if obj.Namespaces == nil {
|
||||
obj.Namespaces = nil
|
||||
func SetDefaults_PodLifeTimeArgs(obj runtime.Object) {
|
||||
args := obj.(*PodLifeTimeArgs)
|
||||
if args.Namespaces == nil {
|
||||
args.Namespaces = nil
|
||||
}
|
||||
if obj.LabelSelector == nil {
|
||||
obj.LabelSelector = nil
|
||||
if args.LabelSelector == nil {
|
||||
args.LabelSelector = nil
|
||||
}
|
||||
if obj.MaxPodLifeTimeSeconds == nil {
|
||||
obj.MaxPodLifeTimeSeconds = nil
|
||||
if args.MaxPodLifeTimeSeconds == nil {
|
||||
args.MaxPodLifeTimeSeconds = nil
|
||||
}
|
||||
if obj.States == nil {
|
||||
obj.States = nil
|
||||
if args.States == nil {
|
||||
args.States = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,16 @@ package podlifetime
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
)
|
||||
|
||||
// ValidatePodLifeTimeArgs validates PodLifeTime arguments
|
||||
func ValidatePodLifeTimeArgs(args *PodLifeTimeArgs) error {
|
||||
func ValidatePodLifeTimeArgs(obj runtime.Object) error {
|
||||
args := obj.(*PodLifeTimeArgs)
|
||||
if args.MaxPodLifeTimeSeconds == nil {
|
||||
return fmt.Errorf("MaxPodLifeTimeSeconds not set")
|
||||
}
|
||||
|
||||
@@ -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(&PodLifeTimeArgs{}, func(obj interface{}) { SetObjectDefaults_PodLifeTimeArgs(obj.(*PodLifeTimeArgs)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PodLifeTimeArgs(in *PodLifeTimeArgs) {
|
||||
SetDefaults_PodLifeTimeArgs(in)
|
||||
}
|
||||
|
||||
@@ -23,11 +23,12 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_RemoveDuplicatesArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_RemoveDuplicatesArgs(obj *RemoveDuplicatesArgs) {
|
||||
if obj.Namespaces == nil {
|
||||
obj.Namespaces = nil
|
||||
func SetDefaults_RemoveDuplicatesArgs(obj runtime.Object) {
|
||||
args := obj.(*RemoveDuplicatesArgs)
|
||||
if args.Namespaces == nil {
|
||||
args.Namespaces = nil
|
||||
}
|
||||
if obj.ExcludeOwnerKinds == nil {
|
||||
obj.ExcludeOwnerKinds = nil
|
||||
if args.ExcludeOwnerKinds == nil {
|
||||
args.ExcludeOwnerKinds = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,12 @@ package removeduplicates
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
func ValidateRemoveDuplicatesArgs(args *RemoveDuplicatesArgs) error {
|
||||
func ValidateRemoveDuplicatesArgs(obj runtime.Object) error {
|
||||
args := obj.(*RemoveDuplicatesArgs)
|
||||
// At most one of include/exclude can be set
|
||||
if args.Namespaces != nil && len(args.Namespaces.Include) > 0 && len(args.Namespaces.Exclude) > 0 {
|
||||
return fmt.Errorf("only one of Include/Exclude namespaces can be set")
|
||||
|
||||
@@ -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(&RemoveDuplicatesArgs{}, func(obj interface{}) { SetObjectDefaults_RemoveDuplicatesArgs(obj.(*RemoveDuplicatesArgs)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_RemoveDuplicatesArgs(in *RemoveDuplicatesArgs) {
|
||||
SetDefaults_RemoveDuplicatesArgs(in)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ package removefailedpods
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
@@ -23,23 +24,24 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_RemoveFailedPodsArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_RemoveFailedPodsArgs(obj *RemoveFailedPodsArgs) {
|
||||
if obj.Namespaces == nil {
|
||||
obj.Namespaces = nil
|
||||
func SetDefaults_RemoveFailedPodsArgs(obj runtime.Object) {
|
||||
args := obj.(*RemoveFailedPodsArgs)
|
||||
if args.Namespaces == nil {
|
||||
args.Namespaces = nil
|
||||
}
|
||||
if obj.LabelSelector == nil {
|
||||
obj.LabelSelector = nil
|
||||
if args.LabelSelector == nil {
|
||||
args.LabelSelector = nil
|
||||
}
|
||||
if obj.ExcludeOwnerKinds == nil {
|
||||
obj.ExcludeOwnerKinds = nil
|
||||
if args.ExcludeOwnerKinds == nil {
|
||||
args.ExcludeOwnerKinds = nil
|
||||
}
|
||||
if obj.MinPodLifetimeSeconds == nil {
|
||||
obj.MinPodLifetimeSeconds = nil
|
||||
if args.MinPodLifetimeSeconds == nil {
|
||||
args.MinPodLifetimeSeconds = utilpointer.Uint(3600)
|
||||
}
|
||||
if obj.Reasons == nil {
|
||||
obj.Reasons = nil
|
||||
if args.Reasons == nil {
|
||||
args.Reasons = nil
|
||||
}
|
||||
if !obj.IncludingInitContainers {
|
||||
obj.IncludingInitContainers = false
|
||||
if !args.IncludingInitContainers {
|
||||
args.IncludingInitContainers = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// ValidateRemoveFailedPodsArgs validates RemoveFailedPods arguments
|
||||
func ValidateRemoveFailedPodsArgs(args *RemoveFailedPodsArgs) error {
|
||||
func ValidateRemoveFailedPodsArgs(obj runtime.Object) error {
|
||||
args := obj.(*RemoveFailedPodsArgs)
|
||||
// At most one of include/exclude can be set
|
||||
if args.Namespaces != nil && len(args.Namespaces.Include) > 0 && len(args.Namespaces.Exclude) > 0 {
|
||||
return fmt.Errorf("only one of Include/Exclude namespaces can be set")
|
||||
|
||||
@@ -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(&RemoveFailedPodsArgs{}, func(obj interface{}) { SetObjectDefaults_RemoveFailedPodsArgs(obj.(*RemoveFailedPodsArgs)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_RemoveFailedPodsArgs(in *RemoveFailedPodsArgs) {
|
||||
SetDefaults_RemoveFailedPodsArgs(in)
|
||||
}
|
||||
|
||||
@@ -23,17 +23,18 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_RemovePodsHavingTooManyRestartsArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_RemovePodsHavingTooManyRestartsArgs(obj *RemovePodsHavingTooManyRestartsArgs) {
|
||||
if obj.Namespaces == nil {
|
||||
obj.Namespaces = nil
|
||||
func SetDefaults_RemovePodsHavingTooManyRestartsArgs(obj runtime.Object) {
|
||||
args := obj.(*RemovePodsHavingTooManyRestartsArgs)
|
||||
if args.Namespaces == nil {
|
||||
args.Namespaces = nil
|
||||
}
|
||||
if obj.LabelSelector == nil {
|
||||
obj.LabelSelector = nil
|
||||
if args.LabelSelector == nil {
|
||||
args.LabelSelector = nil
|
||||
}
|
||||
if obj.PodRestartThreshold == 0 {
|
||||
obj.PodRestartThreshold = 0
|
||||
if args.PodRestartThreshold == 0 {
|
||||
args.PodRestartThreshold = 0
|
||||
}
|
||||
if !obj.IncludingInitContainers {
|
||||
obj.IncludingInitContainers = false
|
||||
if !args.IncludingInitContainers {
|
||||
args.IncludingInitContainers = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// ValidateRemovePodsHavingTooManyRestartsArgs validates RemovePodsHavingTooManyRestarts arguments
|
||||
func ValidateRemovePodsHavingTooManyRestartsArgs(args *RemovePodsHavingTooManyRestartsArgs) error {
|
||||
func ValidateRemovePodsHavingTooManyRestartsArgs(obj runtime.Object) error {
|
||||
args := obj.(*RemovePodsHavingTooManyRestartsArgs)
|
||||
// At most one of include/exclude can be set
|
||||
if args.Namespaces != nil && len(args.Namespaces.Include) > 0 && len(args.Namespaces.Exclude) > 0 {
|
||||
return fmt.Errorf("only one of Include/Exclude namespaces can be set")
|
||||
|
||||
@@ -29,12 +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(&RemovePodsHavingTooManyRestartsArgs{}, func(obj interface{}) {
|
||||
SetObjectDefaults_RemovePodsHavingTooManyRestartsArgs(obj.(*RemovePodsHavingTooManyRestartsArgs))
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_RemovePodsHavingTooManyRestartsArgs(in *RemovePodsHavingTooManyRestartsArgs) {
|
||||
SetDefaults_RemovePodsHavingTooManyRestartsArgs(in)
|
||||
}
|
||||
|
||||
@@ -23,11 +23,12 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_RemovePodsViolatingInterPodAntiAffinityArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_RemovePodsViolatingInterPodAntiAffinityArgs(obj *RemovePodsViolatingInterPodAntiAffinityArgs) {
|
||||
if obj.Namespaces == nil {
|
||||
obj.Namespaces = nil
|
||||
func SetDefaults_RemovePodsViolatingInterPodAntiAffinityArgs(obj runtime.Object) {
|
||||
args := obj.(*RemovePodsViolatingInterPodAntiAffinityArgs)
|
||||
if args.Namespaces == nil {
|
||||
args.Namespaces = nil
|
||||
}
|
||||
if obj.LabelSelector == nil {
|
||||
obj.LabelSelector = nil
|
||||
if args.LabelSelector == nil {
|
||||
args.LabelSelector = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// ValidateRemovePodsViolatingInterPodAntiAffinityArgs validates ValidateRemovePodsViolatingInterPodAntiAffinity arguments
|
||||
func ValidateRemovePodsViolatingInterPodAntiAffinityArgs(args *RemovePodsViolatingInterPodAntiAffinityArgs) error {
|
||||
func ValidateRemovePodsViolatingInterPodAntiAffinityArgs(obj runtime.Object) error {
|
||||
args := obj.(*RemovePodsViolatingInterPodAntiAffinityArgs)
|
||||
// At most one of include/exclude can be set
|
||||
if args.Namespaces != nil && len(args.Namespaces.Include) > 0 && len(args.Namespaces.Exclude) > 0 {
|
||||
return fmt.Errorf("only one of Include/Exclude namespaces can be set")
|
||||
|
||||
@@ -29,12 +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(&RemovePodsViolatingInterPodAntiAffinityArgs{}, func(obj interface{}) {
|
||||
SetObjectDefaults_RemovePodsViolatingInterPodAntiAffinityArgs(obj.(*RemovePodsViolatingInterPodAntiAffinityArgs))
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_RemovePodsViolatingInterPodAntiAffinityArgs(in *RemovePodsViolatingInterPodAntiAffinityArgs) {
|
||||
SetDefaults_RemovePodsViolatingInterPodAntiAffinityArgs(in)
|
||||
}
|
||||
|
||||
@@ -23,11 +23,12 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_RemovePodsViolatingNodeAffinityArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_RemovePodsViolatingNodeAffinityArgs(obj *RemovePodsViolatingNodeAffinityArgs) {
|
||||
if obj.Namespaces == nil {
|
||||
obj.Namespaces = nil
|
||||
func SetDefaults_RemovePodsViolatingNodeAffinityArgs(obj runtime.Object) {
|
||||
args := obj.(*RemovePodsViolatingNodeAffinityArgs)
|
||||
if args.Namespaces == nil {
|
||||
args.Namespaces = nil
|
||||
}
|
||||
if obj.LabelSelector == nil {
|
||||
obj.LabelSelector = nil
|
||||
if args.LabelSelector == nil {
|
||||
args.LabelSelector = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// ValidateRemovePodsViolatingNodeAffinityArgs validates RemovePodsViolatingNodeAffinity arguments
|
||||
func ValidateRemovePodsViolatingNodeAffinityArgs(args *RemovePodsViolatingNodeAffinityArgs) error {
|
||||
func ValidateRemovePodsViolatingNodeAffinityArgs(obj runtime.Object) error {
|
||||
args := obj.(*RemovePodsViolatingNodeAffinityArgs)
|
||||
if args == nil || len(args.NodeAffinityType) == 0 {
|
||||
return fmt.Errorf("nodeAffinityType needs to be set")
|
||||
}
|
||||
|
||||
@@ -29,12 +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(&RemovePodsViolatingNodeAffinityArgs{}, func(obj interface{}) {
|
||||
SetObjectDefaults_RemovePodsViolatingNodeAffinityArgs(obj.(*RemovePodsViolatingNodeAffinityArgs))
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_RemovePodsViolatingNodeAffinityArgs(in *RemovePodsViolatingNodeAffinityArgs) {
|
||||
SetDefaults_RemovePodsViolatingNodeAffinityArgs(in)
|
||||
}
|
||||
|
||||
@@ -23,17 +23,18 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_RemovePodsViolatingNodeTaintsArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_RemovePodsViolatingNodeTaintsArgs(obj *RemovePodsViolatingNodeTaintsArgs) {
|
||||
if obj.Namespaces == nil {
|
||||
obj.Namespaces = nil
|
||||
func SetDefaults_RemovePodsViolatingNodeTaintsArgs(obj runtime.Object) {
|
||||
args := obj.(*RemovePodsViolatingNodeTaintsArgs)
|
||||
if args.Namespaces == nil {
|
||||
args.Namespaces = nil
|
||||
}
|
||||
if obj.LabelSelector == nil {
|
||||
obj.LabelSelector = nil
|
||||
if args.LabelSelector == nil {
|
||||
args.LabelSelector = nil
|
||||
}
|
||||
if !obj.IncludePreferNoSchedule {
|
||||
obj.IncludePreferNoSchedule = false
|
||||
if !args.IncludePreferNoSchedule {
|
||||
args.IncludePreferNoSchedule = false
|
||||
}
|
||||
if obj.ExcludedTaints == nil {
|
||||
obj.ExcludedTaints = nil
|
||||
if args.ExcludedTaints == nil {
|
||||
args.ExcludedTaints = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// ValidateRemovePodsViolatingNodeTaintsArgs validates RemovePodsViolatingNodeTaints arguments
|
||||
func ValidateRemovePodsViolatingNodeTaintsArgs(args *RemovePodsViolatingNodeTaintsArgs) error {
|
||||
func ValidateRemovePodsViolatingNodeTaintsArgs(obj runtime.Object) error {
|
||||
args := obj.(*RemovePodsViolatingNodeTaintsArgs)
|
||||
// At most one of include/exclude can be set
|
||||
if args.Namespaces != nil && len(args.Namespaces.Include) > 0 && len(args.Namespaces.Exclude) > 0 {
|
||||
return fmt.Errorf("only one of Include/Exclude namespaces can be set")
|
||||
|
||||
@@ -29,12 +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(&RemovePodsViolatingNodeTaintsArgs{}, func(obj interface{}) {
|
||||
SetObjectDefaults_RemovePodsViolatingNodeTaintsArgs(obj.(*RemovePodsViolatingNodeTaintsArgs))
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_RemovePodsViolatingNodeTaintsArgs(in *RemovePodsViolatingNodeTaintsArgs) {
|
||||
SetDefaults_RemovePodsViolatingNodeTaintsArgs(in)
|
||||
}
|
||||
|
||||
@@ -23,14 +23,15 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_RemovePodsViolatingTopologySpreadConstraintArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_RemovePodsViolatingTopologySpreadConstraintArgs(obj *RemovePodsViolatingTopologySpreadConstraintArgs) {
|
||||
if obj.Namespaces == nil {
|
||||
obj.Namespaces = nil
|
||||
func SetDefaults_RemovePodsViolatingTopologySpreadConstraintArgs(obj runtime.Object) {
|
||||
args := obj.(*RemovePodsViolatingTopologySpreadConstraintArgs)
|
||||
if args.Namespaces == nil {
|
||||
args.Namespaces = nil
|
||||
}
|
||||
if obj.LabelSelector == nil {
|
||||
obj.LabelSelector = nil
|
||||
if args.LabelSelector == nil {
|
||||
args.LabelSelector = nil
|
||||
}
|
||||
if !obj.IncludeSoftConstraints {
|
||||
obj.IncludeSoftConstraints = false
|
||||
if !args.IncludeSoftConstraints {
|
||||
args.IncludeSoftConstraints = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// ValidateRemovePodsViolatingTopologySpreadConstraintArgs validates RemovePodsViolatingTopologySpreadConstraint arguments
|
||||
func ValidateRemovePodsViolatingTopologySpreadConstraintArgs(args *RemovePodsViolatingTopologySpreadConstraintArgs) error {
|
||||
func ValidateRemovePodsViolatingTopologySpreadConstraintArgs(obj runtime.Object) error {
|
||||
args := obj.(*RemovePodsViolatingTopologySpreadConstraintArgs)
|
||||
// At most one of include/exclude can be set
|
||||
if args.Namespaces != nil && len(args.Namespaces.Include) > 0 && len(args.Namespaces.Exclude) > 0 {
|
||||
return fmt.Errorf("only one of Include/Exclude namespaces can be set")
|
||||
|
||||
@@ -29,12 +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(&RemovePodsViolatingTopologySpreadConstraintArgs{}, func(obj interface{}) {
|
||||
SetObjectDefaults_RemovePodsViolatingTopologySpreadConstraintArgs(obj.(*RemovePodsViolatingTopologySpreadConstraintArgs))
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_RemovePodsViolatingTopologySpreadConstraintArgs(in *RemovePodsViolatingTopologySpreadConstraintArgs) {
|
||||
SetDefaults_RemovePodsViolatingTopologySpreadConstraintArgs(in)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user