diff --git a/pkg/scheduler/apis/config/v1beta3/conversion.go b/pkg/scheduler/apis/config/v1beta3/conversion.go new file mode 100644 index 00000000000..e37daf09c55 --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/conversion.go @@ -0,0 +1,107 @@ +/* +Copyright 2021 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 v1beta3 + +import ( + "fmt" + "sync" + + "k8s.io/apimachinery/pkg/conversion" + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/kube-scheduler/config/v1beta3" + "k8s.io/kubernetes/pkg/scheduler/apis/config" +) + +var ( + // pluginArgConversionScheme is a scheme with internal and v1beta3 registered, + // used for defaulting/converting typed PluginConfig Args. + // Access via getPluginArgConversionScheme() + pluginArgConversionScheme *runtime.Scheme + initPluginArgConversionScheme sync.Once +) + +func GetPluginArgConversionScheme() *runtime.Scheme { + initPluginArgConversionScheme.Do(func() { + // set up the scheme used for plugin arg conversion + pluginArgConversionScheme = runtime.NewScheme() + utilruntime.Must(AddToScheme(pluginArgConversionScheme)) + utilruntime.Must(config.AddToScheme(pluginArgConversionScheme)) + }) + return pluginArgConversionScheme +} + +func Convert_v1beta3_KubeSchedulerConfiguration_To_config_KubeSchedulerConfiguration(in *v1beta3.KubeSchedulerConfiguration, out *config.KubeSchedulerConfiguration, s conversion.Scope) error { + if err := autoConvert_v1beta3_KubeSchedulerConfiguration_To_config_KubeSchedulerConfiguration(in, out, s); err != nil { + return err + } + return convertToInternalPluginConfigArgs(out) +} + +// convertToInternalPluginConfigArgs converts PluginConfig#Args into internal +// types using a scheme, after applying defaults. +func convertToInternalPluginConfigArgs(out *config.KubeSchedulerConfiguration) error { + scheme := GetPluginArgConversionScheme() + for i := range out.Profiles { + prof := &out.Profiles[i] + for j := range prof.PluginConfig { + args := prof.PluginConfig[j].Args + if args == nil { + continue + } + if _, isUnknown := args.(*runtime.Unknown); isUnknown { + continue + } + internalArgs, err := scheme.ConvertToVersion(args, config.SchemeGroupVersion) + if err != nil { + return fmt.Errorf("converting .Profiles[%d].PluginConfig[%d].Args into internal type: %w", i, j, err) + } + prof.PluginConfig[j].Args = internalArgs + } + } + return nil +} + +func Convert_config_KubeSchedulerConfiguration_To_v1beta3_KubeSchedulerConfiguration(in *config.KubeSchedulerConfiguration, out *v1beta3.KubeSchedulerConfiguration, s conversion.Scope) error { + if err := autoConvert_config_KubeSchedulerConfiguration_To_v1beta3_KubeSchedulerConfiguration(in, out, s); err != nil { + return err + } + return convertToExternalPluginConfigArgs(out) +} + +// convertToExternalPluginConfigArgs converts PluginConfig#Args into +// external (versioned) types using a scheme. +func convertToExternalPluginConfigArgs(out *v1beta3.KubeSchedulerConfiguration) error { + scheme := GetPluginArgConversionScheme() + for i := range out.Profiles { + for j := range out.Profiles[i].PluginConfig { + args := out.Profiles[i].PluginConfig[j].Args + if args.Object == nil { + continue + } + if _, isUnknown := args.Object.(*runtime.Unknown); isUnknown { + continue + } + externalArgs, err := scheme.ConvertToVersion(args.Object, SchemeGroupVersion) + if err != nil { + return err + } + out.Profiles[i].PluginConfig[j].Args.Object = externalArgs + } + } + return nil +} diff --git a/pkg/scheduler/apis/config/v1beta3/default_plugins.go b/pkg/scheduler/apis/config/v1beta3/default_plugins.go new file mode 100644 index 00000000000..3d4f35e2f16 --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/default_plugins.go @@ -0,0 +1,201 @@ +/* +Copyright 2021 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 v1beta3 + +import ( + "k8s.io/apimachinery/pkg/util/sets" + utilfeature "k8s.io/apiserver/pkg/util/feature" + "k8s.io/klog/v2" + "k8s.io/kube-scheduler/config/v1beta3" + "k8s.io/kubernetes/pkg/features" + "k8s.io/kubernetes/pkg/scheduler/framework/plugins/names" + "k8s.io/utils/pointer" +) + +// getDefaultPlugins returns the default set of plugins. +func getDefaultPlugins() *v1beta3.Plugins { + plugins := &v1beta3.Plugins{ + QueueSort: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.PrioritySort}, + }, + }, + PreFilter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeResourcesFit}, + {Name: names.NodePorts}, + {Name: names.VolumeRestrictions}, + {Name: names.PodTopologySpread}, + {Name: names.InterPodAffinity}, + {Name: names.VolumeBinding}, + {Name: names.NodeAffinity}, + }, + }, + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeUnschedulable}, + {Name: names.NodeName}, + {Name: names.TaintToleration}, + {Name: names.NodeAffinity}, + {Name: names.NodePorts}, + {Name: names.NodeResourcesFit}, + {Name: names.VolumeRestrictions}, + {Name: names.EBSLimits}, + {Name: names.GCEPDLimits}, + {Name: names.NodeVolumeLimits}, + {Name: names.AzureDiskLimits}, + {Name: names.VolumeBinding}, + {Name: names.VolumeZone}, + {Name: names.PodTopologySpread}, + {Name: names.InterPodAffinity}, + }, + }, + PostFilter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.DefaultPreemption}, + }, + }, + PreScore: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.InterPodAffinity}, + {Name: names.PodTopologySpread}, + {Name: names.TaintToleration}, + {Name: names.NodeAffinity}, + }, + }, + Score: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32Ptr(1)}, + {Name: names.ImageLocality, Weight: pointer.Int32Ptr(1)}, + {Name: names.NodeResourcesFit, Weight: pointer.Int32Ptr(1)}, + // Weight is doubled because: + // - This is a score coming from user preference. + {Name: names.InterPodAffinity, Weight: pointer.Int32Ptr(2)}, + // Weight is doubled because: + // - This is a score coming from user preference. + {Name: names.NodeAffinity, Weight: pointer.Int32Ptr(2)}, + // Weight is doubled because: + // - This is a score coming from user preference. + // - It makes its signal comparable to NodeResourcesFit.LeastAllocated. + {Name: names.PodTopologySpread, Weight: pointer.Int32Ptr(2)}, + // Weight is tripled because: + // - This is a score coming from user preference. + // - Usage of node tainting to group nodes in the cluster is becoming a valid use-case more often + // for many user workloads + {Name: names.TaintToleration, Weight: pointer.Int32Ptr(3)}, + }, + }, + Reserve: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.VolumeBinding}, + }, + }, + PreBind: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.VolumeBinding}, + }, + }, + Bind: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.DefaultBinder}, + }, + }, + } + applyFeatureGates(plugins) + + return plugins +} + +func applyFeatureGates(config *v1beta3.Plugins) { + if utilfeature.DefaultFeatureGate.Enabled(features.VolumeCapacityPriority) { + config.Score.Enabled = append(config.Score.Enabled, v1beta3.Plugin{Name: names.VolumeBinding, Weight: pointer.Int32Ptr(1)}) + } + + if !utilfeature.DefaultFeatureGate.Enabled(features.DefaultPodTopologySpread) { + // When feature is enabled, the default spreading is done by + // PodTopologySpread plugin, which is enabled by default. + klog.InfoS("Registering SelectorSpread plugin") + s := v1beta3.Plugin{Name: names.SelectorSpread} + config.PreScore.Enabled = append(config.PreScore.Enabled, s) + s.Weight = pointer.Int32Ptr(1) + config.Score.Enabled = append(config.Score.Enabled, s) + } +} + +// mergePlugins merges the custom set into the given default one, handling disabled sets. +func mergePlugins(defaultPlugins, customPlugins *v1beta3.Plugins) *v1beta3.Plugins { + if customPlugins == nil { + return defaultPlugins + } + + defaultPlugins.QueueSort = mergePluginSet(defaultPlugins.QueueSort, customPlugins.QueueSort) + defaultPlugins.PreFilter = mergePluginSet(defaultPlugins.PreFilter, customPlugins.PreFilter) + defaultPlugins.Filter = mergePluginSet(defaultPlugins.Filter, customPlugins.Filter) + defaultPlugins.PostFilter = mergePluginSet(defaultPlugins.PostFilter, customPlugins.PostFilter) + defaultPlugins.PreScore = mergePluginSet(defaultPlugins.PreScore, customPlugins.PreScore) + defaultPlugins.Score = mergePluginSet(defaultPlugins.Score, customPlugins.Score) + defaultPlugins.Reserve = mergePluginSet(defaultPlugins.Reserve, customPlugins.Reserve) + defaultPlugins.Permit = mergePluginSet(defaultPlugins.Permit, customPlugins.Permit) + defaultPlugins.PreBind = mergePluginSet(defaultPlugins.PreBind, customPlugins.PreBind) + defaultPlugins.Bind = mergePluginSet(defaultPlugins.Bind, customPlugins.Bind) + defaultPlugins.PostBind = mergePluginSet(defaultPlugins.PostBind, customPlugins.PostBind) + return defaultPlugins +} + +type pluginIndex struct { + index int + plugin v1beta3.Plugin +} + +func mergePluginSet(defaultPluginSet, customPluginSet v1beta3.PluginSet) v1beta3.PluginSet { + disabledPlugins := sets.NewString() + enabledCustomPlugins := make(map[string]pluginIndex) + // replacedPluginIndex is a set of index of plugins, which have replaced the default plugins. + replacedPluginIndex := sets.NewInt() + for _, disabledPlugin := range customPluginSet.Disabled { + disabledPlugins.Insert(disabledPlugin.Name) + } + for index, enabledPlugin := range customPluginSet.Enabled { + enabledCustomPlugins[enabledPlugin.Name] = pluginIndex{index, enabledPlugin} + } + var enabledPlugins []v1beta3.Plugin + if !disabledPlugins.Has("*") { + for _, defaultEnabledPlugin := range defaultPluginSet.Enabled { + if disabledPlugins.Has(defaultEnabledPlugin.Name) { + continue + } + // The default plugin is explicitly re-configured, update the default plugin accordingly. + if customPlugin, ok := enabledCustomPlugins[defaultEnabledPlugin.Name]; ok { + klog.InfoS("Default plugin is explicitly re-configured; overriding", "plugin", defaultEnabledPlugin.Name) + // Update the default plugin in place to preserve order. + defaultEnabledPlugin = customPlugin.plugin + replacedPluginIndex.Insert(customPlugin.index) + } + enabledPlugins = append(enabledPlugins, defaultEnabledPlugin) + } + } + + // Append all the custom plugins which haven't replaced any default plugins. + // Note: duplicated custom plugins will still be appended here. + // If so, the instantiation of scheduler framework will detect it and abort. + for index, plugin := range customPluginSet.Enabled { + if !replacedPluginIndex.Has(index) { + enabledPlugins = append(enabledPlugins, plugin) + } + } + return v1beta3.PluginSet{Enabled: enabledPlugins} +} diff --git a/pkg/scheduler/apis/config/v1beta3/default_plugins_test.go b/pkg/scheduler/apis/config/v1beta3/default_plugins_test.go new file mode 100644 index 00000000000..56cdbe366c3 --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/default_plugins_test.go @@ -0,0 +1,464 @@ +/* +Copyright 2017 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 v1beta3 + +import ( + "k8s.io/kube-scheduler/config/v1beta3" + "testing" + + "github.com/google/go-cmp/cmp" + "k8s.io/apiserver/pkg/util/feature" + "k8s.io/component-base/featuregate" + featuregatetesting "k8s.io/component-base/featuregate/testing" + "k8s.io/kubernetes/pkg/features" + "k8s.io/kubernetes/pkg/scheduler/framework/plugins/names" + "k8s.io/utils/pointer" +) + +func TestApplyFeatureGates(t *testing.T) { + tests := []struct { + name string + features map[featuregate.Feature]bool + wantConfig *v1beta3.Plugins + }{ + { + name: "Feature gates disabled", + wantConfig: &v1beta3.Plugins{ + QueueSort: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.PrioritySort}, + }, + }, + PreFilter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeResourcesFit}, + {Name: names.NodePorts}, + {Name: names.VolumeRestrictions}, + {Name: names.PodTopologySpread}, + {Name: names.InterPodAffinity}, + {Name: names.VolumeBinding}, + {Name: names.NodeAffinity}, + }, + }, + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeUnschedulable}, + {Name: names.NodeName}, + {Name: names.TaintToleration}, + {Name: names.NodeAffinity}, + {Name: names.NodePorts}, + {Name: names.NodeResourcesFit}, + {Name: names.VolumeRestrictions}, + {Name: names.EBSLimits}, + {Name: names.GCEPDLimits}, + {Name: names.NodeVolumeLimits}, + {Name: names.AzureDiskLimits}, + {Name: names.VolumeBinding}, + {Name: names.VolumeZone}, + {Name: names.PodTopologySpread}, + {Name: names.InterPodAffinity}, + }, + }, + PostFilter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.DefaultPreemption}, + }, + }, + PreScore: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.InterPodAffinity}, + {Name: names.PodTopologySpread}, + {Name: names.TaintToleration}, + {Name: names.NodeAffinity}, + }, + }, + Score: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32Ptr(1)}, + {Name: names.ImageLocality, Weight: pointer.Int32Ptr(1)}, + {Name: names.NodeResourcesFit, Weight: pointer.Int32Ptr(1)}, + {Name: names.InterPodAffinity, Weight: pointer.Int32Ptr(2)}, + {Name: names.NodeAffinity, Weight: pointer.Int32Ptr(2)}, + {Name: names.PodTopologySpread, Weight: pointer.Int32Ptr(2)}, + {Name: names.TaintToleration, Weight: pointer.Int32Ptr(3)}, + }, + }, + Reserve: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.VolumeBinding}, + }, + }, + PreBind: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.VolumeBinding}, + }, + }, + Bind: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.DefaultBinder}, + }, + }, + }, + }, + { + name: "DefaultPodTopologySpread disabled", + features: map[featuregate.Feature]bool{ + features.DefaultPodTopologySpread: false, + }, + wantConfig: &v1beta3.Plugins{ + QueueSort: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.PrioritySort}, + }, + }, + PreFilter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeResourcesFit}, + {Name: names.NodePorts}, + {Name: names.VolumeRestrictions}, + {Name: names.PodTopologySpread}, + {Name: names.InterPodAffinity}, + {Name: names.VolumeBinding}, + {Name: names.NodeAffinity}, + }, + }, + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeUnschedulable}, + {Name: names.NodeName}, + {Name: names.TaintToleration}, + {Name: names.NodeAffinity}, + {Name: names.NodePorts}, + {Name: names.NodeResourcesFit}, + {Name: names.VolumeRestrictions}, + {Name: names.EBSLimits}, + {Name: names.GCEPDLimits}, + {Name: names.NodeVolumeLimits}, + {Name: names.AzureDiskLimits}, + {Name: names.VolumeBinding}, + {Name: names.VolumeZone}, + {Name: names.PodTopologySpread}, + {Name: names.InterPodAffinity}, + }, + }, + PostFilter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.DefaultPreemption}, + }, + }, + PreScore: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.InterPodAffinity}, + {Name: names.PodTopologySpread}, + {Name: names.TaintToleration}, + {Name: names.NodeAffinity}, + {Name: names.SelectorSpread}, + }, + }, + Score: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32Ptr(1)}, + {Name: names.ImageLocality, Weight: pointer.Int32Ptr(1)}, + {Name: names.NodeResourcesFit, Weight: pointer.Int32Ptr(1)}, + {Name: names.InterPodAffinity, Weight: pointer.Int32Ptr(2)}, + {Name: names.NodeAffinity, Weight: pointer.Int32Ptr(2)}, + {Name: names.PodTopologySpread, Weight: pointer.Int32Ptr(2)}, + {Name: names.TaintToleration, Weight: pointer.Int32Ptr(3)}, + {Name: names.SelectorSpread, Weight: pointer.Int32Ptr(1)}, + }, + }, + Reserve: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.VolumeBinding}, + }, + }, + PreBind: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.VolumeBinding}, + }, + }, + Bind: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.DefaultBinder}, + }, + }, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + for k, v := range test.features { + defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, k, v)() + } + + gotConfig := getDefaultPlugins() + if diff := cmp.Diff(test.wantConfig, gotConfig); diff != "" { + t.Errorf("unexpected config diff (-want, +got): %s", diff) + } + }) + } +} + +func TestMergePlugins(t *testing.T) { + tests := []struct { + name string + customPlugins *v1beta3.Plugins + defaultPlugins *v1beta3.Plugins + expectedPlugins *v1beta3.Plugins + }{ + { + name: "AppendCustomPlugin", + customPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "CustomPlugin"}, + }, + }, + }, + defaultPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin1"}, + {Name: "DefaultPlugin2"}, + }, + }, + }, + expectedPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin1"}, + {Name: "DefaultPlugin2"}, + {Name: "CustomPlugin"}, + }, + }, + }, + }, + { + name: "InsertAfterDefaultPlugins2", + customPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "CustomPlugin"}, + {Name: "DefaultPlugin2"}, + }, + Disabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin2"}, + }, + }, + }, + defaultPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin1"}, + {Name: "DefaultPlugin2"}, + }, + }, + }, + expectedPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin1"}, + {Name: "CustomPlugin"}, + {Name: "DefaultPlugin2"}, + }, + }, + }, + }, + { + name: "InsertBeforeAllPlugins", + customPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "CustomPlugin"}, + {Name: "DefaultPlugin1"}, + {Name: "DefaultPlugin2"}, + }, + Disabled: []v1beta3.Plugin{ + {Name: "*"}, + }, + }, + }, + defaultPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin1"}, + {Name: "DefaultPlugin2"}, + }, + }, + }, + expectedPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "CustomPlugin"}, + {Name: "DefaultPlugin1"}, + {Name: "DefaultPlugin2"}, + }, + }, + }, + }, + { + name: "ReorderDefaultPlugins", + customPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin2"}, + {Name: "DefaultPlugin1"}, + }, + Disabled: []v1beta3.Plugin{ + {Name: "*"}, + }, + }, + }, + defaultPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin1"}, + {Name: "DefaultPlugin2"}, + }, + }, + }, + expectedPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin2"}, + {Name: "DefaultPlugin1"}, + }, + }, + }, + }, + { + name: "ApplyNilCustomPlugin", + customPlugins: nil, + defaultPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin1"}, + {Name: "DefaultPlugin2"}, + }, + }, + }, + expectedPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "DefaultPlugin1"}, + {Name: "DefaultPlugin2"}, + }, + }, + }, + }, + { + name: "CustomPluginOverrideDefaultPlugin", + customPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "Plugin1", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin3", Weight: pointer.Int32Ptr(3)}, + }, + }, + }, + defaultPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "Plugin1"}, + {Name: "Plugin2"}, + {Name: "Plugin3"}, + }, + }, + }, + expectedPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "Plugin1", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin2"}, + {Name: "Plugin3", Weight: pointer.Int32Ptr(3)}, + }, + }, + }, + }, + { + name: "OrderPreserveAfterOverride", + customPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin1", Weight: pointer.Int32Ptr(1)}, + }, + }, + }, + defaultPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "Plugin1"}, + {Name: "Plugin2"}, + {Name: "Plugin3"}, + }, + }, + }, + expectedPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "Plugin1", Weight: pointer.Int32Ptr(1)}, + {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin3"}, + }, + }, + }, + }, + { + name: "RepeatedCustomPlugin", + customPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "Plugin1"}, + {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin3"}, + {Name: "Plugin2", Weight: pointer.Int32Ptr(4)}, + }, + }, + }, + defaultPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "Plugin1"}, + {Name: "Plugin2"}, + {Name: "Plugin3"}, + }, + }, + }, + expectedPlugins: &v1beta3.Plugins{ + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "Plugin1"}, + {Name: "Plugin2", Weight: pointer.Int32Ptr(4)}, + {Name: "Plugin3"}, + {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + }, + }, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + test.defaultPlugins = mergePlugins(test.defaultPlugins, test.customPlugins) + if d := cmp.Diff(test.expectedPlugins, test.defaultPlugins); d != "" { + t.Fatalf("plugins mismatch (-want +got):\n%s", d) + } + }) + } +} diff --git a/pkg/scheduler/apis/config/v1beta3/defaults.go b/pkg/scheduler/apis/config/v1beta3/defaults.go new file mode 100644 index 00000000000..cd2929a541b --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/defaults.go @@ -0,0 +1,257 @@ +/* +Copyright 2021 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 v1beta3 + +import ( + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/apiserver/pkg/util/feature" + componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1" + "k8s.io/kube-scheduler/config/v1beta3" + "k8s.io/kubernetes/pkg/features" + "k8s.io/kubernetes/pkg/scheduler/apis/config" + "k8s.io/utils/pointer" +) + +var defaultResourceSpec = []v1beta3.ResourceSpec{ + {Name: string(v1.ResourceCPU), Weight: 1}, + {Name: string(v1.ResourceMemory), Weight: 1}, +} + +func addDefaultingFuncs(scheme *runtime.Scheme) error { + return RegisterDefaults(scheme) +} + +func pluginsNames(p *v1beta3.Plugins) []string { + if p == nil { + return nil + } + extensions := []v1beta3.PluginSet{ + p.PreFilter, + p.Filter, + p.PostFilter, + p.Reserve, + p.PreScore, + p.Score, + p.PreBind, + p.Bind, + p.PostBind, + p.Permit, + p.QueueSort, + } + n := sets.NewString() + for _, e := range extensions { + for _, pg := range e.Enabled { + n.Insert(pg.Name) + } + } + return n.List() +} + +func setDefaults_KubeSchedulerProfile(prof *v1beta3.KubeSchedulerProfile) { + // Set default plugins. + prof.Plugins = mergePlugins(getDefaultPlugins(), prof.Plugins) + + // Set default plugin configs. + scheme := GetPluginArgConversionScheme() + existingConfigs := sets.NewString() + for j := range prof.PluginConfig { + existingConfigs.Insert(prof.PluginConfig[j].Name) + args := prof.PluginConfig[j].Args.Object + if _, isUnknown := args.(*runtime.Unknown); isUnknown { + continue + } + scheme.Default(args) + } + + // Append default configs for plugins that didn't have one explicitly set. + for _, name := range pluginsNames(prof.Plugins) { + if existingConfigs.Has(name) { + continue + } + gvk := v1beta3.SchemeGroupVersion.WithKind(name + "Args") + args, err := scheme.New(gvk) + if err != nil { + // This plugin is out-of-tree or doesn't require configuration. + continue + } + scheme.Default(args) + args.GetObjectKind().SetGroupVersionKind(gvk) + prof.PluginConfig = append(prof.PluginConfig, v1beta3.PluginConfig{ + Name: name, + Args: runtime.RawExtension{Object: args}, + }) + } +} + +// SetDefaults_KubeSchedulerConfiguration sets additional defaults +func SetDefaults_KubeSchedulerConfiguration(obj *v1beta3.KubeSchedulerConfiguration) { + if obj.Parallelism == nil { + obj.Parallelism = pointer.Int32Ptr(16) + } + + if len(obj.Profiles) == 0 { + obj.Profiles = append(obj.Profiles, v1beta3.KubeSchedulerProfile{}) + } + // Only apply a default scheduler name when there is a single profile. + // Validation will ensure that every profile has a non-empty unique name. + if len(obj.Profiles) == 1 && obj.Profiles[0].SchedulerName == nil { + obj.Profiles[0].SchedulerName = pointer.StringPtr(v1.DefaultSchedulerName) + } + + // Add the default set of plugins and apply the configuration. + for i := range obj.Profiles { + prof := &obj.Profiles[i] + setDefaults_KubeSchedulerProfile(prof) + } + + if obj.PercentageOfNodesToScore == nil { + percentageOfNodesToScore := int32(config.DefaultPercentageOfNodesToScore) + obj.PercentageOfNodesToScore = &percentageOfNodesToScore + } + + if len(obj.LeaderElection.ResourceLock) == 0 { + // Use lease-based leader election to reduce cost. + // We migrated for EndpointsLease lock in 1.17 and starting in 1.20 we + // migrated to Lease lock. + obj.LeaderElection.ResourceLock = "leases" + } + if len(obj.LeaderElection.ResourceNamespace) == 0 { + obj.LeaderElection.ResourceNamespace = v1beta3.SchedulerDefaultLockObjectNamespace + } + if len(obj.LeaderElection.ResourceName) == 0 { + obj.LeaderElection.ResourceName = v1beta3.SchedulerDefaultLockObjectName + } + + if len(obj.ClientConnection.ContentType) == 0 { + obj.ClientConnection.ContentType = "application/vnd.kubernetes.protobuf" + } + // Scheduler has an opinion about QPS/Burst, setting specific defaults for itself, instead of generic settings. + if obj.ClientConnection.QPS == 0.0 { + obj.ClientConnection.QPS = 50.0 + } + if obj.ClientConnection.Burst == 0 { + obj.ClientConnection.Burst = 100 + } + + // Use the default LeaderElectionConfiguration options + componentbaseconfigv1alpha1.RecommendedDefaultLeaderElectionConfiguration(&obj.LeaderElection) + + if obj.PodInitialBackoffSeconds == nil { + val := int64(1) + obj.PodInitialBackoffSeconds = &val + } + + if obj.PodMaxBackoffSeconds == nil { + val := int64(10) + obj.PodMaxBackoffSeconds = &val + } + + // Enable profiling by default in the scheduler + if obj.EnableProfiling == nil { + enableProfiling := true + obj.EnableProfiling = &enableProfiling + } + + // Enable contention profiling by default if profiling is enabled + if *obj.EnableProfiling && obj.EnableContentionProfiling == nil { + enableContentionProfiling := true + obj.EnableContentionProfiling = &enableContentionProfiling + } +} + +func SetDefaults_DefaultPreemptionArgs(obj *v1beta3.DefaultPreemptionArgs) { + if obj.MinCandidateNodesPercentage == nil { + obj.MinCandidateNodesPercentage = pointer.Int32Ptr(10) + } + if obj.MinCandidateNodesAbsolute == nil { + obj.MinCandidateNodesAbsolute = pointer.Int32Ptr(100) + } +} + +func SetDefaults_InterPodAffinityArgs(obj *v1beta3.InterPodAffinityArgs) { + // Note that an object is created manually in cmd/kube-scheduler/app/options/deprecated.go + // DeprecatedOptions#ApplyTo. + // Update that object if a new default field is added here. + if obj.HardPodAffinityWeight == nil { + obj.HardPodAffinityWeight = pointer.Int32Ptr(1) + } +} + +func SetDefaults_VolumeBindingArgs(obj *v1beta3.VolumeBindingArgs) { + if obj.BindTimeoutSeconds == nil { + obj.BindTimeoutSeconds = pointer.Int64Ptr(600) + } + if len(obj.Shape) == 0 && feature.DefaultFeatureGate.Enabled(features.VolumeCapacityPriority) { + obj.Shape = []v1beta3.UtilizationShapePoint{ + { + Utilization: 0, + Score: 0, + }, + { + Utilization: 100, + Score: int32(config.MaxCustomPriorityScore), + }, + } + } +} + +func SetDefaults_NodeResourcesBalancedAllocationArgs(obj *v1beta3.NodeResourcesBalancedAllocationArgs) { + if len(obj.Resources) == 0 { + obj.Resources = append(obj.Resources, + v1beta3.ResourceSpec{Name: string(v1.ResourceCPU), Weight: 1}, + v1beta3.ResourceSpec{Name: string(v1.ResourceMemory), Weight: 1}, + ) + } + // If the weight is not set or it is explicitly set to 0, then apply the default weight(1) instead. + for i := range obj.Resources { + if obj.Resources[i].Weight == 0 { + obj.Resources[i].Weight = 1 + } + } +} + +func SetDefaults_PodTopologySpreadArgs(obj *v1beta3.PodTopologySpreadArgs) { + if feature.DefaultFeatureGate.Enabled(features.DefaultPodTopologySpread) { + if obj.DefaultingType == "" { + obj.DefaultingType = v1beta3.SystemDefaulting + } + return + } + if obj.DefaultingType == "" { + obj.DefaultingType = v1beta3.ListDefaulting + } +} + +func SetDefaults_NodeResourcesFitArgs(obj *v1beta3.NodeResourcesFitArgs) { + if obj.ScoringStrategy == nil { + obj.ScoringStrategy = &v1beta3.ScoringStrategy{ + Type: v1beta3.ScoringStrategyType(config.LeastAllocated), + Resources: defaultResourceSpec, + } + } + if len(obj.ScoringStrategy.Resources) == 0 { + // If no resources specified, use the default set. + obj.ScoringStrategy.Resources = append(obj.ScoringStrategy.Resources, defaultResourceSpec...) + } + for i := range obj.ScoringStrategy.Resources { + if obj.ScoringStrategy.Resources[i].Weight == 0 { + obj.ScoringStrategy.Resources[i].Weight = 1 + } + } +} diff --git a/pkg/scheduler/apis/config/v1beta3/defaults_test.go b/pkg/scheduler/apis/config/v1beta3/defaults_test.go new file mode 100644 index 00000000000..d0cb48b40d5 --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/defaults_test.go @@ -0,0 +1,698 @@ +/* +Copyright 2021 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 v1beta3 + +import ( + "testing" + "time" + + "github.com/google/go-cmp/cmp" + + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apiserver/pkg/util/feature" + componentbaseconfig "k8s.io/component-base/config/v1alpha1" + "k8s.io/component-base/featuregate" + featuregatetesting "k8s.io/component-base/featuregate/testing" + "k8s.io/kube-scheduler/config/v1beta3" + "k8s.io/kubernetes/pkg/features" + "k8s.io/kubernetes/pkg/scheduler/framework/plugins/names" + "k8s.io/utils/pointer" +) + +var pluginConfigs = []v1beta3.PluginConfig{ + { + Name: "DefaultPreemption", + Args: runtime.RawExtension{ + Object: &v1beta3.DefaultPreemptionArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "DefaultPreemptionArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + MinCandidateNodesPercentage: pointer.Int32Ptr(10), + MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + }}, + }, + { + Name: "InterPodAffinity", + Args: runtime.RawExtension{ + Object: &v1beta3.InterPodAffinityArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "InterPodAffinityArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + HardPodAffinityWeight: pointer.Int32Ptr(1), + }}, + }, + { + Name: "NodeAffinity", + Args: runtime.RawExtension{Object: &v1beta3.NodeAffinityArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "NodeAffinityArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + }}, + }, + { + Name: "NodeResourcesBalancedAllocation", + Args: runtime.RawExtension{Object: &v1beta3.NodeResourcesBalancedAllocationArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "NodeResourcesBalancedAllocationArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + Resources: []v1beta3.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}}, + }}, + }, + { + Name: "NodeResourcesFit", + Args: runtime.RawExtension{Object: &v1beta3.NodeResourcesFitArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "NodeResourcesFitArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + ScoringStrategy: &v1beta3.ScoringStrategy{ + Type: v1beta3.LeastAllocated, + Resources: []v1beta3.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}}, + }, + }}, + }, + { + Name: "PodTopologySpread", + Args: runtime.RawExtension{Object: &v1beta3.PodTopologySpreadArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "PodTopologySpreadArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + DefaultingType: v1beta3.SystemDefaulting, + }}, + }, + { + Name: "VolumeBinding", + Args: runtime.RawExtension{Object: &v1beta3.VolumeBindingArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "VolumeBindingArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + BindTimeoutSeconds: pointer.Int64Ptr(600), + }}, + }, +} + +func TestSchedulerDefaults(t *testing.T) { + enable := true + tests := []struct { + name string + config *v1beta3.KubeSchedulerConfiguration + expected *v1beta3.KubeSchedulerConfiguration + }{ + { + name: "empty config", + config: &v1beta3.KubeSchedulerConfiguration{}, + expected: &v1beta3.KubeSchedulerConfiguration{ + Parallelism: pointer.Int32Ptr(16), + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: &enable, + EnableContentionProfiling: &enable, + }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "leases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", + }, + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ + QPS: 50, + Burst: 100, + ContentType: "application/vnd.kubernetes.protobuf", + }, + PercentageOfNodesToScore: pointer.Int32Ptr(0), + PodInitialBackoffSeconds: pointer.Int64Ptr(1), + PodMaxBackoffSeconds: pointer.Int64Ptr(10), + Profiles: []v1beta3.KubeSchedulerProfile{ + { + Plugins: getDefaultPlugins(), + PluginConfig: pluginConfigs, + SchedulerName: pointer.StringPtr("default-scheduler"), + }, + }, + }, + }, + { + name: "no scheduler name", + config: &v1beta3.KubeSchedulerConfiguration{ + Profiles: []v1beta3.KubeSchedulerProfile{{}}, + }, + expected: &v1beta3.KubeSchedulerConfiguration{ + Parallelism: pointer.Int32Ptr(16), + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: &enable, + EnableContentionProfiling: &enable, + }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "leases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", + }, + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ + QPS: 50, + Burst: 100, + ContentType: "application/vnd.kubernetes.protobuf", + }, + PercentageOfNodesToScore: pointer.Int32Ptr(0), + PodInitialBackoffSeconds: pointer.Int64Ptr(1), + PodMaxBackoffSeconds: pointer.Int64Ptr(10), + Profiles: []v1beta3.KubeSchedulerProfile{ + { + SchedulerName: pointer.StringPtr("default-scheduler"), + Plugins: getDefaultPlugins(), + PluginConfig: pluginConfigs}, + }, + }, + }, + { + name: "two profiles", + config: &v1beta3.KubeSchedulerConfiguration{ + Parallelism: pointer.Int32Ptr(16), + Profiles: []v1beta3.KubeSchedulerProfile{ + { + PluginConfig: []v1beta3.PluginConfig{ + {Name: "FooPlugin"}, + }, + }, + { + SchedulerName: pointer.StringPtr("custom-scheduler"), + Plugins: &v1beta3.Plugins{ + Bind: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "BarPlugin"}, + }, + Disabled: []v1beta3.Plugin{ + {Name: names.DefaultBinder}, + }, + }, + }, + }, + }, + }, + expected: &v1beta3.KubeSchedulerConfiguration{ + Parallelism: pointer.Int32Ptr(16), + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: &enable, + EnableContentionProfiling: &enable, + }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "leases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", + }, + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ + QPS: 50, + Burst: 100, + ContentType: "application/vnd.kubernetes.protobuf", + }, + PercentageOfNodesToScore: pointer.Int32Ptr(0), + PodInitialBackoffSeconds: pointer.Int64Ptr(1), + PodMaxBackoffSeconds: pointer.Int64Ptr(10), + Profiles: []v1beta3.KubeSchedulerProfile{ + { + Plugins: getDefaultPlugins(), + PluginConfig: []v1beta3.PluginConfig{ + {Name: "FooPlugin"}, + { + Name: "DefaultPreemption", + Args: runtime.RawExtension{ + Object: &v1beta3.DefaultPreemptionArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "DefaultPreemptionArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + MinCandidateNodesPercentage: pointer.Int32Ptr(10), + MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + }}, + }, + { + Name: "InterPodAffinity", + Args: runtime.RawExtension{ + Object: &v1beta3.InterPodAffinityArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "InterPodAffinityArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + HardPodAffinityWeight: pointer.Int32Ptr(1), + }}, + }, + { + Name: "NodeAffinity", + Args: runtime.RawExtension{Object: &v1beta3.NodeAffinityArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "NodeAffinityArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + }}, + }, + { + Name: "NodeResourcesBalancedAllocation", + Args: runtime.RawExtension{Object: &v1beta3.NodeResourcesBalancedAllocationArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "NodeResourcesBalancedAllocationArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + Resources: []v1beta3.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}}, + }}, + }, + { + Name: "NodeResourcesFit", + Args: runtime.RawExtension{Object: &v1beta3.NodeResourcesFitArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "NodeResourcesFitArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + ScoringStrategy: &v1beta3.ScoringStrategy{ + Type: v1beta3.LeastAllocated, + Resources: []v1beta3.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}}, + }, + }}, + }, + { + Name: "PodTopologySpread", + Args: runtime.RawExtension{Object: &v1beta3.PodTopologySpreadArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "PodTopologySpreadArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + DefaultingType: v1beta3.SystemDefaulting, + }}, + }, + { + Name: "VolumeBinding", + Args: runtime.RawExtension{Object: &v1beta3.VolumeBindingArgs{ + TypeMeta: metav1.TypeMeta{ + Kind: "VolumeBindingArgs", + APIVersion: "kubescheduler.config.k8s.io/v1beta3", + }, + BindTimeoutSeconds: pointer.Int64Ptr(600), + }}, + }, + }, + }, + { + SchedulerName: pointer.StringPtr("custom-scheduler"), + Plugins: &v1beta3.Plugins{ + QueueSort: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.PrioritySort}, + }, + }, + PreFilter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeResourcesFit}, + {Name: names.NodePorts}, + {Name: names.VolumeRestrictions}, + {Name: names.PodTopologySpread}, + {Name: names.InterPodAffinity}, + {Name: names.VolumeBinding}, + {Name: names.NodeAffinity}, + }, + }, + Filter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeUnschedulable}, + {Name: names.NodeName}, + {Name: names.TaintToleration}, + {Name: names.NodeAffinity}, + {Name: names.NodePorts}, + {Name: names.NodeResourcesFit}, + {Name: names.VolumeRestrictions}, + {Name: names.EBSLimits}, + {Name: names.GCEPDLimits}, + {Name: names.NodeVolumeLimits}, + {Name: names.AzureDiskLimits}, + {Name: names.VolumeBinding}, + {Name: names.VolumeZone}, + {Name: names.PodTopologySpread}, + {Name: names.InterPodAffinity}, + }, + }, + PostFilter: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.DefaultPreemption}, + }, + }, + PreScore: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.InterPodAffinity}, + {Name: names.PodTopologySpread}, + {Name: names.TaintToleration}, + {Name: names.NodeAffinity}, + }, + }, + Score: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32Ptr(1)}, + {Name: names.ImageLocality, Weight: pointer.Int32Ptr(1)}, + {Name: names.NodeResourcesFit, Weight: pointer.Int32Ptr(1)}, + {Name: names.InterPodAffinity, Weight: pointer.Int32Ptr(2)}, + {Name: names.NodeAffinity, Weight: pointer.Int32Ptr(2)}, + {Name: names.PodTopologySpread, Weight: pointer.Int32Ptr(2)}, + {Name: names.TaintToleration, Weight: pointer.Int32Ptr(3)}, + }, + }, + Reserve: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.VolumeBinding}, + }, + }, + PreBind: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: names.VolumeBinding}, + }, + }, + Bind: v1beta3.PluginSet{ + Enabled: []v1beta3.Plugin{ + {Name: "BarPlugin"}, + }, + }, + }, + PluginConfig: pluginConfigs, + }, + }, + }, + }, + { + name: "Prallelism with no port", + config: &v1beta3.KubeSchedulerConfiguration{ + Parallelism: pointer.Int32Ptr(16), + }, + expected: &v1beta3.KubeSchedulerConfiguration{ + Parallelism: pointer.Int32Ptr(16), + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: &enable, + EnableContentionProfiling: &enable, + }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "leases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", + }, + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ + QPS: 50, + Burst: 100, + ContentType: "application/vnd.kubernetes.protobuf", + }, + PercentageOfNodesToScore: pointer.Int32Ptr(0), + PodInitialBackoffSeconds: pointer.Int64Ptr(1), + PodMaxBackoffSeconds: pointer.Int64Ptr(10), + Profiles: []v1beta3.KubeSchedulerProfile{ + { + Plugins: getDefaultPlugins(), + PluginConfig: pluginConfigs, + SchedulerName: pointer.StringPtr("default-scheduler"), + }, + }, + }, + }, + { + name: "set non default parallelism", + config: &v1beta3.KubeSchedulerConfiguration{ + Parallelism: pointer.Int32Ptr(8), + }, + expected: &v1beta3.KubeSchedulerConfiguration{ + Parallelism: pointer.Int32Ptr(8), + DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ + EnableProfiling: &enable, + EnableContentionProfiling: &enable, + }, + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ + LeaderElect: pointer.BoolPtr(true), + LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, + RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, + RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, + ResourceLock: "leases", + ResourceNamespace: "kube-system", + ResourceName: "kube-scheduler", + }, + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ + QPS: 50, + Burst: 100, + ContentType: "application/vnd.kubernetes.protobuf", + }, + PercentageOfNodesToScore: pointer.Int32Ptr(0), + PodInitialBackoffSeconds: pointer.Int64Ptr(1), + PodMaxBackoffSeconds: pointer.Int64Ptr(10), + Profiles: []v1beta3.KubeSchedulerProfile{ + { + Plugins: getDefaultPlugins(), + PluginConfig: pluginConfigs, + SchedulerName: pointer.StringPtr("default-scheduler"), + }, + }, + }, + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + SetDefaults_KubeSchedulerConfiguration(tc.config) + if diff := cmp.Diff(tc.expected, tc.config); diff != "" { + t.Errorf("Got unexpected defaults (-want, +got):\n%s", diff) + } + }) + } +} + +func TestPluginArgsDefaults(t *testing.T) { + tests := []struct { + name string + features map[featuregate.Feature]bool + in runtime.Object + want runtime.Object + }{ + { + name: "DefaultPreemptionArgs empty", + in: &v1beta3.DefaultPreemptionArgs{}, + want: &v1beta3.DefaultPreemptionArgs{ + MinCandidateNodesPercentage: pointer.Int32Ptr(10), + MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + }, + }, + { + name: "DefaultPreemptionArgs with value", + in: &v1beta3.DefaultPreemptionArgs{ + MinCandidateNodesPercentage: pointer.Int32Ptr(50), + }, + want: &v1beta3.DefaultPreemptionArgs{ + MinCandidateNodesPercentage: pointer.Int32Ptr(50), + MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + }, + }, + { + name: "InterPodAffinityArgs empty", + in: &v1beta3.InterPodAffinityArgs{}, + want: &v1beta3.InterPodAffinityArgs{ + HardPodAffinityWeight: pointer.Int32Ptr(1), + }, + }, + { + name: "InterPodAffinityArgs explicit 0", + in: &v1beta3.InterPodAffinityArgs{ + HardPodAffinityWeight: pointer.Int32Ptr(0), + }, + want: &v1beta3.InterPodAffinityArgs{ + HardPodAffinityWeight: pointer.Int32Ptr(0), + }, + }, + { + name: "InterPodAffinityArgs with value", + in: &v1beta3.InterPodAffinityArgs{ + HardPodAffinityWeight: pointer.Int32Ptr(5), + }, + want: &v1beta3.InterPodAffinityArgs{ + HardPodAffinityWeight: pointer.Int32Ptr(5), + }, + }, + { + name: "NodeResourcesBalancedAllocationArgs resources empty", + in: &v1beta3.NodeResourcesBalancedAllocationArgs{}, + want: &v1beta3.NodeResourcesBalancedAllocationArgs{ + Resources: []v1beta3.ResourceSpec{ + {Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}, + }, + }, + }, + { + name: "NodeResourcesBalancedAllocationArgs with scalar resource", + in: &v1beta3.NodeResourcesBalancedAllocationArgs{ + Resources: []v1beta3.ResourceSpec{ + {Name: "scalar.io/scalar1", Weight: 1}, + }, + }, + want: &v1beta3.NodeResourcesBalancedAllocationArgs{ + Resources: []v1beta3.ResourceSpec{ + {Name: "scalar.io/scalar1", Weight: 1}, + }, + }, + }, + { + name: "NodeResourcesBalancedAllocationArgs with mixed resources", + in: &v1beta3.NodeResourcesBalancedAllocationArgs{ + Resources: []v1beta3.ResourceSpec{ + {Name: string(v1.ResourceCPU), Weight: 1}, + {Name: "scalar.io/scalar1", Weight: 1}, + }, + }, + want: &v1beta3.NodeResourcesBalancedAllocationArgs{ + Resources: []v1beta3.ResourceSpec{ + {Name: string(v1.ResourceCPU), Weight: 1}, + {Name: "scalar.io/scalar1", Weight: 1}, + }, + }, + }, + { + name: "NodeResourcesBalancedAllocationArgs have resource no weight", + in: &v1beta3.NodeResourcesBalancedAllocationArgs{ + Resources: []v1beta3.ResourceSpec{ + {Name: string(v1.ResourceCPU)}, + {Name: "scalar.io/scalar0"}, + {Name: "scalar.io/scalar1", Weight: 1}, + }, + }, + want: &v1beta3.NodeResourcesBalancedAllocationArgs{ + Resources: []v1beta3.ResourceSpec{ + {Name: string(v1.ResourceCPU), Weight: 1}, + {Name: "scalar.io/scalar0", Weight: 1}, + {Name: "scalar.io/scalar1", Weight: 1}, + }, + }, + }, + { + name: "PodTopologySpreadArgs resources empty", + in: &v1beta3.PodTopologySpreadArgs{}, + want: &v1beta3.PodTopologySpreadArgs{ + DefaultingType: v1beta3.SystemDefaulting, + }, + }, + { + name: "PodTopologySpreadArgs resources with value", + in: &v1beta3.PodTopologySpreadArgs{ + DefaultConstraints: []v1.TopologySpreadConstraint{ + { + TopologyKey: "planet", + WhenUnsatisfiable: v1.DoNotSchedule, + MaxSkew: 2, + }, + }, + }, + want: &v1beta3.PodTopologySpreadArgs{ + DefaultConstraints: []v1.TopologySpreadConstraint{ + { + TopologyKey: "planet", + WhenUnsatisfiable: v1.DoNotSchedule, + MaxSkew: 2, + }, + }, + DefaultingType: v1beta3.SystemDefaulting, + }, + }, + { + name: "PodTopologySpreadArgs empty, DefaultPodTopologySpread feature disabled", + features: map[featuregate.Feature]bool{ + features.DefaultPodTopologySpread: false, + }, + in: &v1beta3.PodTopologySpreadArgs{}, + want: &v1beta3.PodTopologySpreadArgs{ + DefaultingType: v1beta3.ListDefaulting, + }, + }, + { + name: "NodeResourcesFitArgs not set", + in: &v1beta3.NodeResourcesFitArgs{}, + want: &v1beta3.NodeResourcesFitArgs{ + ScoringStrategy: &v1beta3.ScoringStrategy{ + Type: v1beta3.LeastAllocated, + Resources: defaultResourceSpec, + }, + }, + }, + { + name: "NodeResourcesFitArgs Resources empty", + in: &v1beta3.NodeResourcesFitArgs{ + ScoringStrategy: &v1beta3.ScoringStrategy{ + Type: v1beta3.MostAllocated, + }, + }, + want: &v1beta3.NodeResourcesFitArgs{ + ScoringStrategy: &v1beta3.ScoringStrategy{ + Type: v1beta3.MostAllocated, + Resources: defaultResourceSpec, + }, + }, + }, + { + name: "VolumeBindingArgs empty, VolumeCapacityPriority disabled", + features: map[featuregate.Feature]bool{ + features.VolumeCapacityPriority: false, + }, + in: &v1beta3.VolumeBindingArgs{}, + want: &v1beta3.VolumeBindingArgs{ + BindTimeoutSeconds: pointer.Int64Ptr(600), + }, + }, + { + name: "VolumeBindingArgs empty, VolumeCapacityPriority enabled", + features: map[featuregate.Feature]bool{ + features.VolumeCapacityPriority: true, + }, + in: &v1beta3.VolumeBindingArgs{}, + want: &v1beta3.VolumeBindingArgs{ + BindTimeoutSeconds: pointer.Int64Ptr(600), + Shape: []v1beta3.UtilizationShapePoint{ + {Utilization: 0, Score: 0}, + {Utilization: 100, Score: 10}, + }, + }, + }, + } + for _, tc := range tests { + scheme := runtime.NewScheme() + utilruntime.Must(AddToScheme(scheme)) + t.Run(tc.name, func(t *testing.T) { + for k, v := range tc.features { + defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, k, v)() + } + scheme.Default(tc.in) + if diff := cmp.Diff(tc.in, tc.want); diff != "" { + t.Errorf("Got unexpected defaults (-want, +got):\n%s", diff) + } + }) + } +} diff --git a/pkg/scheduler/apis/config/v1beta3/doc.go b/pkg/scheduler/apis/config/v1beta3/doc.go new file mode 100644 index 00000000000..e9976588f13 --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/doc.go @@ -0,0 +1,24 @@ +/* +Copyright 2021 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. +*/ + +// +k8s:deepcopy-gen=package +// +k8s:conversion-gen=k8s.io/kubernetes/pkg/scheduler/apis/config +// +k8s:conversion-gen-external-types=k8s.io/kube-scheduler/config/v1beta3 +// +k8s:defaulter-gen=TypeMeta +// +k8s:defaulter-gen-input=k8s.io/kube-scheduler/config/v1beta3 +// +groupName=kubescheduler.config.k8s.io + +package v1beta3 // import "k8s.io/kubernetes/pkg/scheduler/apis/config/v1beta3" diff --git a/pkg/scheduler/apis/config/v1beta3/register.go b/pkg/scheduler/apis/config/v1beta3/register.go new file mode 100644 index 00000000000..2af0952e6f7 --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/register.go @@ -0,0 +1,42 @@ +/* +Copyright 2021 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 v1beta3 + +import ( + "k8s.io/kube-scheduler/config/v1beta3" +) + +// GroupName is the group name used in this package +const GroupName = v1beta3.GroupName + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = v1beta3.SchemeGroupVersion + +var ( + // localSchemeBuilder extends the SchemeBuilder instance with the external types. In this package, + // defaulting and conversion init funcs are registered as well. + localSchemeBuilder = &v1beta3.SchemeBuilder + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addDefaultingFuncs) +} diff --git a/pkg/scheduler/apis/config/v1beta3/zz_generated.conversion.go b/pkg/scheduler/apis/config/v1beta3/zz_generated.conversion.go new file mode 100644 index 00000000000..2a2fccd12b7 --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/zz_generated.conversion.go @@ -0,0 +1,859 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by conversion-gen. DO NOT EDIT. + +package v1beta3 + +import ( + unsafe "unsafe" + + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + v1alpha1 "k8s.io/component-base/config/v1alpha1" + configv1 "k8s.io/kube-scheduler/config/v1" + v1beta3 "k8s.io/kube-scheduler/config/v1beta3" + config "k8s.io/kubernetes/pkg/scheduler/apis/config" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*v1beta3.DefaultPreemptionArgs)(nil), (*config.DefaultPreemptionArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_DefaultPreemptionArgs_To_config_DefaultPreemptionArgs(a.(*v1beta3.DefaultPreemptionArgs), b.(*config.DefaultPreemptionArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.DefaultPreemptionArgs)(nil), (*v1beta3.DefaultPreemptionArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_DefaultPreemptionArgs_To_v1beta3_DefaultPreemptionArgs(a.(*config.DefaultPreemptionArgs), b.(*v1beta3.DefaultPreemptionArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.Extender)(nil), (*config.Extender)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_Extender_To_config_Extender(a.(*v1beta3.Extender), b.(*config.Extender), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.Extender)(nil), (*v1beta3.Extender)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_Extender_To_v1beta3_Extender(a.(*config.Extender), b.(*v1beta3.Extender), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.InterPodAffinityArgs)(nil), (*config.InterPodAffinityArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_InterPodAffinityArgs_To_config_InterPodAffinityArgs(a.(*v1beta3.InterPodAffinityArgs), b.(*config.InterPodAffinityArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.InterPodAffinityArgs)(nil), (*v1beta3.InterPodAffinityArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_InterPodAffinityArgs_To_v1beta3_InterPodAffinityArgs(a.(*config.InterPodAffinityArgs), b.(*v1beta3.InterPodAffinityArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.KubeSchedulerProfile)(nil), (*config.KubeSchedulerProfile)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_KubeSchedulerProfile_To_config_KubeSchedulerProfile(a.(*v1beta3.KubeSchedulerProfile), b.(*config.KubeSchedulerProfile), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.KubeSchedulerProfile)(nil), (*v1beta3.KubeSchedulerProfile)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_KubeSchedulerProfile_To_v1beta3_KubeSchedulerProfile(a.(*config.KubeSchedulerProfile), b.(*v1beta3.KubeSchedulerProfile), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.NodeAffinityArgs)(nil), (*config.NodeAffinityArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_NodeAffinityArgs_To_config_NodeAffinityArgs(a.(*v1beta3.NodeAffinityArgs), b.(*config.NodeAffinityArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.NodeAffinityArgs)(nil), (*v1beta3.NodeAffinityArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_NodeAffinityArgs_To_v1beta3_NodeAffinityArgs(a.(*config.NodeAffinityArgs), b.(*v1beta3.NodeAffinityArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.NodeResourcesBalancedAllocationArgs)(nil), (*config.NodeResourcesBalancedAllocationArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_NodeResourcesBalancedAllocationArgs_To_config_NodeResourcesBalancedAllocationArgs(a.(*v1beta3.NodeResourcesBalancedAllocationArgs), b.(*config.NodeResourcesBalancedAllocationArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.NodeResourcesBalancedAllocationArgs)(nil), (*v1beta3.NodeResourcesBalancedAllocationArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_NodeResourcesBalancedAllocationArgs_To_v1beta3_NodeResourcesBalancedAllocationArgs(a.(*config.NodeResourcesBalancedAllocationArgs), b.(*v1beta3.NodeResourcesBalancedAllocationArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.NodeResourcesFitArgs)(nil), (*config.NodeResourcesFitArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_NodeResourcesFitArgs_To_config_NodeResourcesFitArgs(a.(*v1beta3.NodeResourcesFitArgs), b.(*config.NodeResourcesFitArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.NodeResourcesFitArgs)(nil), (*v1beta3.NodeResourcesFitArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_NodeResourcesFitArgs_To_v1beta3_NodeResourcesFitArgs(a.(*config.NodeResourcesFitArgs), b.(*v1beta3.NodeResourcesFitArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.Plugin)(nil), (*config.Plugin)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_Plugin_To_config_Plugin(a.(*v1beta3.Plugin), b.(*config.Plugin), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.Plugin)(nil), (*v1beta3.Plugin)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_Plugin_To_v1beta3_Plugin(a.(*config.Plugin), b.(*v1beta3.Plugin), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.PluginConfig)(nil), (*config.PluginConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_PluginConfig_To_config_PluginConfig(a.(*v1beta3.PluginConfig), b.(*config.PluginConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.PluginConfig)(nil), (*v1beta3.PluginConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_PluginConfig_To_v1beta3_PluginConfig(a.(*config.PluginConfig), b.(*v1beta3.PluginConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.PluginSet)(nil), (*config.PluginSet)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_PluginSet_To_config_PluginSet(a.(*v1beta3.PluginSet), b.(*config.PluginSet), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.PluginSet)(nil), (*v1beta3.PluginSet)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_PluginSet_To_v1beta3_PluginSet(a.(*config.PluginSet), b.(*v1beta3.PluginSet), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.Plugins)(nil), (*config.Plugins)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_Plugins_To_config_Plugins(a.(*v1beta3.Plugins), b.(*config.Plugins), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.Plugins)(nil), (*v1beta3.Plugins)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_Plugins_To_v1beta3_Plugins(a.(*config.Plugins), b.(*v1beta3.Plugins), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.PodTopologySpreadArgs)(nil), (*config.PodTopologySpreadArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_PodTopologySpreadArgs_To_config_PodTopologySpreadArgs(a.(*v1beta3.PodTopologySpreadArgs), b.(*config.PodTopologySpreadArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.PodTopologySpreadArgs)(nil), (*v1beta3.PodTopologySpreadArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_PodTopologySpreadArgs_To_v1beta3_PodTopologySpreadArgs(a.(*config.PodTopologySpreadArgs), b.(*v1beta3.PodTopologySpreadArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.RequestedToCapacityRatioParam)(nil), (*config.RequestedToCapacityRatioParam)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_RequestedToCapacityRatioParam_To_config_RequestedToCapacityRatioParam(a.(*v1beta3.RequestedToCapacityRatioParam), b.(*config.RequestedToCapacityRatioParam), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.RequestedToCapacityRatioParam)(nil), (*v1beta3.RequestedToCapacityRatioParam)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_RequestedToCapacityRatioParam_To_v1beta3_RequestedToCapacityRatioParam(a.(*config.RequestedToCapacityRatioParam), b.(*v1beta3.RequestedToCapacityRatioParam), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.ResourceSpec)(nil), (*config.ResourceSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_ResourceSpec_To_config_ResourceSpec(a.(*v1beta3.ResourceSpec), b.(*config.ResourceSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.ResourceSpec)(nil), (*v1beta3.ResourceSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_ResourceSpec_To_v1beta3_ResourceSpec(a.(*config.ResourceSpec), b.(*v1beta3.ResourceSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.ScoringStrategy)(nil), (*config.ScoringStrategy)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_ScoringStrategy_To_config_ScoringStrategy(a.(*v1beta3.ScoringStrategy), b.(*config.ScoringStrategy), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.ScoringStrategy)(nil), (*v1beta3.ScoringStrategy)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_ScoringStrategy_To_v1beta3_ScoringStrategy(a.(*config.ScoringStrategy), b.(*v1beta3.ScoringStrategy), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.UtilizationShapePoint)(nil), (*config.UtilizationShapePoint)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_UtilizationShapePoint_To_config_UtilizationShapePoint(a.(*v1beta3.UtilizationShapePoint), b.(*config.UtilizationShapePoint), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.UtilizationShapePoint)(nil), (*v1beta3.UtilizationShapePoint)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_UtilizationShapePoint_To_v1beta3_UtilizationShapePoint(a.(*config.UtilizationShapePoint), b.(*v1beta3.UtilizationShapePoint), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta3.VolumeBindingArgs)(nil), (*config.VolumeBindingArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_VolumeBindingArgs_To_config_VolumeBindingArgs(a.(*v1beta3.VolumeBindingArgs), b.(*config.VolumeBindingArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.VolumeBindingArgs)(nil), (*v1beta3.VolumeBindingArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_VolumeBindingArgs_To_v1beta3_VolumeBindingArgs(a.(*config.VolumeBindingArgs), b.(*v1beta3.VolumeBindingArgs), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*config.KubeSchedulerConfiguration)(nil), (*v1beta3.KubeSchedulerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_KubeSchedulerConfiguration_To_v1beta3_KubeSchedulerConfiguration(a.(*config.KubeSchedulerConfiguration), b.(*v1beta3.KubeSchedulerConfiguration), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta3.KubeSchedulerConfiguration)(nil), (*config.KubeSchedulerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta3_KubeSchedulerConfiguration_To_config_KubeSchedulerConfiguration(a.(*v1beta3.KubeSchedulerConfiguration), b.(*config.KubeSchedulerConfiguration), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1beta3_DefaultPreemptionArgs_To_config_DefaultPreemptionArgs(in *v1beta3.DefaultPreemptionArgs, out *config.DefaultPreemptionArgs, s conversion.Scope) error { + if err := v1.Convert_Pointer_int32_To_int32(&in.MinCandidateNodesPercentage, &out.MinCandidateNodesPercentage, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.MinCandidateNodesAbsolute, &out.MinCandidateNodesAbsolute, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta3_DefaultPreemptionArgs_To_config_DefaultPreemptionArgs is an autogenerated conversion function. +func Convert_v1beta3_DefaultPreemptionArgs_To_config_DefaultPreemptionArgs(in *v1beta3.DefaultPreemptionArgs, out *config.DefaultPreemptionArgs, s conversion.Scope) error { + return autoConvert_v1beta3_DefaultPreemptionArgs_To_config_DefaultPreemptionArgs(in, out, s) +} + +func autoConvert_config_DefaultPreemptionArgs_To_v1beta3_DefaultPreemptionArgs(in *config.DefaultPreemptionArgs, out *v1beta3.DefaultPreemptionArgs, s conversion.Scope) error { + if err := v1.Convert_int32_To_Pointer_int32(&in.MinCandidateNodesPercentage, &out.MinCandidateNodesPercentage, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.MinCandidateNodesAbsolute, &out.MinCandidateNodesAbsolute, s); err != nil { + return err + } + return nil +} + +// Convert_config_DefaultPreemptionArgs_To_v1beta3_DefaultPreemptionArgs is an autogenerated conversion function. +func Convert_config_DefaultPreemptionArgs_To_v1beta3_DefaultPreemptionArgs(in *config.DefaultPreemptionArgs, out *v1beta3.DefaultPreemptionArgs, s conversion.Scope) error { + return autoConvert_config_DefaultPreemptionArgs_To_v1beta3_DefaultPreemptionArgs(in, out, s) +} + +func autoConvert_v1beta3_Extender_To_config_Extender(in *v1beta3.Extender, out *config.Extender, s conversion.Scope) error { + out.URLPrefix = in.URLPrefix + out.FilterVerb = in.FilterVerb + out.PreemptVerb = in.PreemptVerb + out.PrioritizeVerb = in.PrioritizeVerb + out.Weight = in.Weight + out.BindVerb = in.BindVerb + out.EnableHTTPS = in.EnableHTTPS + out.TLSConfig = (*config.ExtenderTLSConfig)(unsafe.Pointer(in.TLSConfig)) + out.HTTPTimeout = in.HTTPTimeout + out.NodeCacheCapable = in.NodeCacheCapable + out.ManagedResources = *(*[]config.ExtenderManagedResource)(unsafe.Pointer(&in.ManagedResources)) + out.Ignorable = in.Ignorable + return nil +} + +// Convert_v1beta3_Extender_To_config_Extender is an autogenerated conversion function. +func Convert_v1beta3_Extender_To_config_Extender(in *v1beta3.Extender, out *config.Extender, s conversion.Scope) error { + return autoConvert_v1beta3_Extender_To_config_Extender(in, out, s) +} + +func autoConvert_config_Extender_To_v1beta3_Extender(in *config.Extender, out *v1beta3.Extender, s conversion.Scope) error { + out.URLPrefix = in.URLPrefix + out.FilterVerb = in.FilterVerb + out.PreemptVerb = in.PreemptVerb + out.PrioritizeVerb = in.PrioritizeVerb + out.Weight = in.Weight + out.BindVerb = in.BindVerb + out.EnableHTTPS = in.EnableHTTPS + out.TLSConfig = (*configv1.ExtenderTLSConfig)(unsafe.Pointer(in.TLSConfig)) + out.HTTPTimeout = in.HTTPTimeout + out.NodeCacheCapable = in.NodeCacheCapable + out.ManagedResources = *(*[]configv1.ExtenderManagedResource)(unsafe.Pointer(&in.ManagedResources)) + out.Ignorable = in.Ignorable + return nil +} + +// Convert_config_Extender_To_v1beta3_Extender is an autogenerated conversion function. +func Convert_config_Extender_To_v1beta3_Extender(in *config.Extender, out *v1beta3.Extender, s conversion.Scope) error { + return autoConvert_config_Extender_To_v1beta3_Extender(in, out, s) +} + +func autoConvert_v1beta3_InterPodAffinityArgs_To_config_InterPodAffinityArgs(in *v1beta3.InterPodAffinityArgs, out *config.InterPodAffinityArgs, s conversion.Scope) error { + if err := v1.Convert_Pointer_int32_To_int32(&in.HardPodAffinityWeight, &out.HardPodAffinityWeight, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta3_InterPodAffinityArgs_To_config_InterPodAffinityArgs is an autogenerated conversion function. +func Convert_v1beta3_InterPodAffinityArgs_To_config_InterPodAffinityArgs(in *v1beta3.InterPodAffinityArgs, out *config.InterPodAffinityArgs, s conversion.Scope) error { + return autoConvert_v1beta3_InterPodAffinityArgs_To_config_InterPodAffinityArgs(in, out, s) +} + +func autoConvert_config_InterPodAffinityArgs_To_v1beta3_InterPodAffinityArgs(in *config.InterPodAffinityArgs, out *v1beta3.InterPodAffinityArgs, s conversion.Scope) error { + if err := v1.Convert_int32_To_Pointer_int32(&in.HardPodAffinityWeight, &out.HardPodAffinityWeight, s); err != nil { + return err + } + return nil +} + +// Convert_config_InterPodAffinityArgs_To_v1beta3_InterPodAffinityArgs is an autogenerated conversion function. +func Convert_config_InterPodAffinityArgs_To_v1beta3_InterPodAffinityArgs(in *config.InterPodAffinityArgs, out *v1beta3.InterPodAffinityArgs, s conversion.Scope) error { + return autoConvert_config_InterPodAffinityArgs_To_v1beta3_InterPodAffinityArgs(in, out, s) +} + +func autoConvert_v1beta3_KubeSchedulerConfiguration_To_config_KubeSchedulerConfiguration(in *v1beta3.KubeSchedulerConfiguration, out *config.KubeSchedulerConfiguration, s conversion.Scope) error { + if err := v1.Convert_Pointer_int32_To_int32(&in.Parallelism, &out.Parallelism, s); err != nil { + return err + } + if err := v1alpha1.Convert_v1alpha1_LeaderElectionConfiguration_To_config_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil { + return err + } + if err := v1alpha1.Convert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(&in.ClientConnection, &out.ClientConnection, s); err != nil { + return err + } + if err := v1alpha1.Convert_v1alpha1_DebuggingConfiguration_To_config_DebuggingConfiguration(&in.DebuggingConfiguration, &out.DebuggingConfiguration, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.PercentageOfNodesToScore, &out.PercentageOfNodesToScore, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int64_To_int64(&in.PodInitialBackoffSeconds, &out.PodInitialBackoffSeconds, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int64_To_int64(&in.PodMaxBackoffSeconds, &out.PodMaxBackoffSeconds, s); err != nil { + return err + } + if in.Profiles != nil { + in, out := &in.Profiles, &out.Profiles + *out = make([]config.KubeSchedulerProfile, len(*in)) + for i := range *in { + if err := Convert_v1beta3_KubeSchedulerProfile_To_config_KubeSchedulerProfile(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Profiles = nil + } + out.Extenders = *(*[]config.Extender)(unsafe.Pointer(&in.Extenders)) + return nil +} + +func autoConvert_config_KubeSchedulerConfiguration_To_v1beta3_KubeSchedulerConfiguration(in *config.KubeSchedulerConfiguration, out *v1beta3.KubeSchedulerConfiguration, s conversion.Scope) error { + if err := v1.Convert_int32_To_Pointer_int32(&in.Parallelism, &out.Parallelism, s); err != nil { + return err + } + if err := v1alpha1.Convert_config_LeaderElectionConfiguration_To_v1alpha1_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil { + return err + } + if err := v1alpha1.Convert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(&in.ClientConnection, &out.ClientConnection, s); err != nil { + return err + } + // WARNING: in.HealthzBindAddress requires manual conversion: does not exist in peer-type + // WARNING: in.MetricsBindAddress requires manual conversion: does not exist in peer-type + if err := v1alpha1.Convert_config_DebuggingConfiguration_To_v1alpha1_DebuggingConfiguration(&in.DebuggingConfiguration, &out.DebuggingConfiguration, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.PercentageOfNodesToScore, &out.PercentageOfNodesToScore, s); err != nil { + return err + } + if err := v1.Convert_int64_To_Pointer_int64(&in.PodInitialBackoffSeconds, &out.PodInitialBackoffSeconds, s); err != nil { + return err + } + if err := v1.Convert_int64_To_Pointer_int64(&in.PodMaxBackoffSeconds, &out.PodMaxBackoffSeconds, s); err != nil { + return err + } + if in.Profiles != nil { + in, out := &in.Profiles, &out.Profiles + *out = make([]v1beta3.KubeSchedulerProfile, len(*in)) + for i := range *in { + if err := Convert_config_KubeSchedulerProfile_To_v1beta3_KubeSchedulerProfile(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Profiles = nil + } + out.Extenders = *(*[]v1beta3.Extender)(unsafe.Pointer(&in.Extenders)) + return nil +} + +func autoConvert_v1beta3_KubeSchedulerProfile_To_config_KubeSchedulerProfile(in *v1beta3.KubeSchedulerProfile, out *config.KubeSchedulerProfile, s conversion.Scope) error { + if err := v1.Convert_Pointer_string_To_string(&in.SchedulerName, &out.SchedulerName, s); err != nil { + return err + } + if in.Plugins != nil { + in, out := &in.Plugins, &out.Plugins + *out = new(config.Plugins) + if err := Convert_v1beta3_Plugins_To_config_Plugins(*in, *out, s); err != nil { + return err + } + } else { + out.Plugins = nil + } + if in.PluginConfig != nil { + in, out := &in.PluginConfig, &out.PluginConfig + *out = make([]config.PluginConfig, len(*in)) + for i := range *in { + if err := Convert_v1beta3_PluginConfig_To_config_PluginConfig(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.PluginConfig = nil + } + return nil +} + +// Convert_v1beta3_KubeSchedulerProfile_To_config_KubeSchedulerProfile is an autogenerated conversion function. +func Convert_v1beta3_KubeSchedulerProfile_To_config_KubeSchedulerProfile(in *v1beta3.KubeSchedulerProfile, out *config.KubeSchedulerProfile, s conversion.Scope) error { + return autoConvert_v1beta3_KubeSchedulerProfile_To_config_KubeSchedulerProfile(in, out, s) +} + +func autoConvert_config_KubeSchedulerProfile_To_v1beta3_KubeSchedulerProfile(in *config.KubeSchedulerProfile, out *v1beta3.KubeSchedulerProfile, s conversion.Scope) error { + if err := v1.Convert_string_To_Pointer_string(&in.SchedulerName, &out.SchedulerName, s); err != nil { + return err + } + if in.Plugins != nil { + in, out := &in.Plugins, &out.Plugins + *out = new(v1beta3.Plugins) + if err := Convert_config_Plugins_To_v1beta3_Plugins(*in, *out, s); err != nil { + return err + } + } else { + out.Plugins = nil + } + if in.PluginConfig != nil { + in, out := &in.PluginConfig, &out.PluginConfig + *out = make([]v1beta3.PluginConfig, len(*in)) + for i := range *in { + if err := Convert_config_PluginConfig_To_v1beta3_PluginConfig(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.PluginConfig = nil + } + return nil +} + +// Convert_config_KubeSchedulerProfile_To_v1beta3_KubeSchedulerProfile is an autogenerated conversion function. +func Convert_config_KubeSchedulerProfile_To_v1beta3_KubeSchedulerProfile(in *config.KubeSchedulerProfile, out *v1beta3.KubeSchedulerProfile, s conversion.Scope) error { + return autoConvert_config_KubeSchedulerProfile_To_v1beta3_KubeSchedulerProfile(in, out, s) +} + +func autoConvert_v1beta3_NodeAffinityArgs_To_config_NodeAffinityArgs(in *v1beta3.NodeAffinityArgs, out *config.NodeAffinityArgs, s conversion.Scope) error { + out.AddedAffinity = (*corev1.NodeAffinity)(unsafe.Pointer(in.AddedAffinity)) + return nil +} + +// Convert_v1beta3_NodeAffinityArgs_To_config_NodeAffinityArgs is an autogenerated conversion function. +func Convert_v1beta3_NodeAffinityArgs_To_config_NodeAffinityArgs(in *v1beta3.NodeAffinityArgs, out *config.NodeAffinityArgs, s conversion.Scope) error { + return autoConvert_v1beta3_NodeAffinityArgs_To_config_NodeAffinityArgs(in, out, s) +} + +func autoConvert_config_NodeAffinityArgs_To_v1beta3_NodeAffinityArgs(in *config.NodeAffinityArgs, out *v1beta3.NodeAffinityArgs, s conversion.Scope) error { + out.AddedAffinity = (*corev1.NodeAffinity)(unsafe.Pointer(in.AddedAffinity)) + return nil +} + +// Convert_config_NodeAffinityArgs_To_v1beta3_NodeAffinityArgs is an autogenerated conversion function. +func Convert_config_NodeAffinityArgs_To_v1beta3_NodeAffinityArgs(in *config.NodeAffinityArgs, out *v1beta3.NodeAffinityArgs, s conversion.Scope) error { + return autoConvert_config_NodeAffinityArgs_To_v1beta3_NodeAffinityArgs(in, out, s) +} + +func autoConvert_v1beta3_NodeResourcesBalancedAllocationArgs_To_config_NodeResourcesBalancedAllocationArgs(in *v1beta3.NodeResourcesBalancedAllocationArgs, out *config.NodeResourcesBalancedAllocationArgs, s conversion.Scope) error { + out.Resources = *(*[]config.ResourceSpec)(unsafe.Pointer(&in.Resources)) + return nil +} + +// Convert_v1beta3_NodeResourcesBalancedAllocationArgs_To_config_NodeResourcesBalancedAllocationArgs is an autogenerated conversion function. +func Convert_v1beta3_NodeResourcesBalancedAllocationArgs_To_config_NodeResourcesBalancedAllocationArgs(in *v1beta3.NodeResourcesBalancedAllocationArgs, out *config.NodeResourcesBalancedAllocationArgs, s conversion.Scope) error { + return autoConvert_v1beta3_NodeResourcesBalancedAllocationArgs_To_config_NodeResourcesBalancedAllocationArgs(in, out, s) +} + +func autoConvert_config_NodeResourcesBalancedAllocationArgs_To_v1beta3_NodeResourcesBalancedAllocationArgs(in *config.NodeResourcesBalancedAllocationArgs, out *v1beta3.NodeResourcesBalancedAllocationArgs, s conversion.Scope) error { + out.Resources = *(*[]v1beta3.ResourceSpec)(unsafe.Pointer(&in.Resources)) + return nil +} + +// Convert_config_NodeResourcesBalancedAllocationArgs_To_v1beta3_NodeResourcesBalancedAllocationArgs is an autogenerated conversion function. +func Convert_config_NodeResourcesBalancedAllocationArgs_To_v1beta3_NodeResourcesBalancedAllocationArgs(in *config.NodeResourcesBalancedAllocationArgs, out *v1beta3.NodeResourcesBalancedAllocationArgs, s conversion.Scope) error { + return autoConvert_config_NodeResourcesBalancedAllocationArgs_To_v1beta3_NodeResourcesBalancedAllocationArgs(in, out, s) +} + +func autoConvert_v1beta3_NodeResourcesFitArgs_To_config_NodeResourcesFitArgs(in *v1beta3.NodeResourcesFitArgs, out *config.NodeResourcesFitArgs, s conversion.Scope) error { + out.IgnoredResources = *(*[]string)(unsafe.Pointer(&in.IgnoredResources)) + out.IgnoredResourceGroups = *(*[]string)(unsafe.Pointer(&in.IgnoredResourceGroups)) + out.ScoringStrategy = (*config.ScoringStrategy)(unsafe.Pointer(in.ScoringStrategy)) + return nil +} + +// Convert_v1beta3_NodeResourcesFitArgs_To_config_NodeResourcesFitArgs is an autogenerated conversion function. +func Convert_v1beta3_NodeResourcesFitArgs_To_config_NodeResourcesFitArgs(in *v1beta3.NodeResourcesFitArgs, out *config.NodeResourcesFitArgs, s conversion.Scope) error { + return autoConvert_v1beta3_NodeResourcesFitArgs_To_config_NodeResourcesFitArgs(in, out, s) +} + +func autoConvert_config_NodeResourcesFitArgs_To_v1beta3_NodeResourcesFitArgs(in *config.NodeResourcesFitArgs, out *v1beta3.NodeResourcesFitArgs, s conversion.Scope) error { + out.IgnoredResources = *(*[]string)(unsafe.Pointer(&in.IgnoredResources)) + out.IgnoredResourceGroups = *(*[]string)(unsafe.Pointer(&in.IgnoredResourceGroups)) + out.ScoringStrategy = (*v1beta3.ScoringStrategy)(unsafe.Pointer(in.ScoringStrategy)) + return nil +} + +// Convert_config_NodeResourcesFitArgs_To_v1beta3_NodeResourcesFitArgs is an autogenerated conversion function. +func Convert_config_NodeResourcesFitArgs_To_v1beta3_NodeResourcesFitArgs(in *config.NodeResourcesFitArgs, out *v1beta3.NodeResourcesFitArgs, s conversion.Scope) error { + return autoConvert_config_NodeResourcesFitArgs_To_v1beta3_NodeResourcesFitArgs(in, out, s) +} + +func autoConvert_v1beta3_Plugin_To_config_Plugin(in *v1beta3.Plugin, out *config.Plugin, s conversion.Scope) error { + out.Name = in.Name + if err := v1.Convert_Pointer_int32_To_int32(&in.Weight, &out.Weight, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta3_Plugin_To_config_Plugin is an autogenerated conversion function. +func Convert_v1beta3_Plugin_To_config_Plugin(in *v1beta3.Plugin, out *config.Plugin, s conversion.Scope) error { + return autoConvert_v1beta3_Plugin_To_config_Plugin(in, out, s) +} + +func autoConvert_config_Plugin_To_v1beta3_Plugin(in *config.Plugin, out *v1beta3.Plugin, s conversion.Scope) error { + out.Name = in.Name + if err := v1.Convert_int32_To_Pointer_int32(&in.Weight, &out.Weight, s); err != nil { + return err + } + return nil +} + +// Convert_config_Plugin_To_v1beta3_Plugin is an autogenerated conversion function. +func Convert_config_Plugin_To_v1beta3_Plugin(in *config.Plugin, out *v1beta3.Plugin, s conversion.Scope) error { + return autoConvert_config_Plugin_To_v1beta3_Plugin(in, out, s) +} + +func autoConvert_v1beta3_PluginConfig_To_config_PluginConfig(in *v1beta3.PluginConfig, out *config.PluginConfig, s conversion.Scope) error { + out.Name = in.Name + if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.Args, &out.Args, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta3_PluginConfig_To_config_PluginConfig is an autogenerated conversion function. +func Convert_v1beta3_PluginConfig_To_config_PluginConfig(in *v1beta3.PluginConfig, out *config.PluginConfig, s conversion.Scope) error { + return autoConvert_v1beta3_PluginConfig_To_config_PluginConfig(in, out, s) +} + +func autoConvert_config_PluginConfig_To_v1beta3_PluginConfig(in *config.PluginConfig, out *v1beta3.PluginConfig, s conversion.Scope) error { + out.Name = in.Name + if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.Args, &out.Args, s); err != nil { + return err + } + return nil +} + +// Convert_config_PluginConfig_To_v1beta3_PluginConfig is an autogenerated conversion function. +func Convert_config_PluginConfig_To_v1beta3_PluginConfig(in *config.PluginConfig, out *v1beta3.PluginConfig, s conversion.Scope) error { + return autoConvert_config_PluginConfig_To_v1beta3_PluginConfig(in, out, s) +} + +func autoConvert_v1beta3_PluginSet_To_config_PluginSet(in *v1beta3.PluginSet, out *config.PluginSet, s conversion.Scope) error { + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = make([]config.Plugin, len(*in)) + for i := range *in { + if err := Convert_v1beta3_Plugin_To_config_Plugin(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Enabled = nil + } + if in.Disabled != nil { + in, out := &in.Disabled, &out.Disabled + *out = make([]config.Plugin, len(*in)) + for i := range *in { + if err := Convert_v1beta3_Plugin_To_config_Plugin(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Disabled = nil + } + return nil +} + +// Convert_v1beta3_PluginSet_To_config_PluginSet is an autogenerated conversion function. +func Convert_v1beta3_PluginSet_To_config_PluginSet(in *v1beta3.PluginSet, out *config.PluginSet, s conversion.Scope) error { + return autoConvert_v1beta3_PluginSet_To_config_PluginSet(in, out, s) +} + +func autoConvert_config_PluginSet_To_v1beta3_PluginSet(in *config.PluginSet, out *v1beta3.PluginSet, s conversion.Scope) error { + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = make([]v1beta3.Plugin, len(*in)) + for i := range *in { + if err := Convert_config_Plugin_To_v1beta3_Plugin(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Enabled = nil + } + if in.Disabled != nil { + in, out := &in.Disabled, &out.Disabled + *out = make([]v1beta3.Plugin, len(*in)) + for i := range *in { + if err := Convert_config_Plugin_To_v1beta3_Plugin(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Disabled = nil + } + return nil +} + +// Convert_config_PluginSet_To_v1beta3_PluginSet is an autogenerated conversion function. +func Convert_config_PluginSet_To_v1beta3_PluginSet(in *config.PluginSet, out *v1beta3.PluginSet, s conversion.Scope) error { + return autoConvert_config_PluginSet_To_v1beta3_PluginSet(in, out, s) +} + +func autoConvert_v1beta3_Plugins_To_config_Plugins(in *v1beta3.Plugins, out *config.Plugins, s conversion.Scope) error { + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.QueueSort, &out.QueueSort, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.PreFilter, &out.PreFilter, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.Filter, &out.Filter, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.PostFilter, &out.PostFilter, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.PreScore, &out.PreScore, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.Score, &out.Score, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.Reserve, &out.Reserve, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.Permit, &out.Permit, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.PreBind, &out.PreBind, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.Bind, &out.Bind, s); err != nil { + return err + } + if err := Convert_v1beta3_PluginSet_To_config_PluginSet(&in.PostBind, &out.PostBind, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta3_Plugins_To_config_Plugins is an autogenerated conversion function. +func Convert_v1beta3_Plugins_To_config_Plugins(in *v1beta3.Plugins, out *config.Plugins, s conversion.Scope) error { + return autoConvert_v1beta3_Plugins_To_config_Plugins(in, out, s) +} + +func autoConvert_config_Plugins_To_v1beta3_Plugins(in *config.Plugins, out *v1beta3.Plugins, s conversion.Scope) error { + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.QueueSort, &out.QueueSort, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.PreFilter, &out.PreFilter, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.Filter, &out.Filter, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.PostFilter, &out.PostFilter, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.PreScore, &out.PreScore, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.Score, &out.Score, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.Reserve, &out.Reserve, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.Permit, &out.Permit, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.PreBind, &out.PreBind, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.Bind, &out.Bind, s); err != nil { + return err + } + if err := Convert_config_PluginSet_To_v1beta3_PluginSet(&in.PostBind, &out.PostBind, s); err != nil { + return err + } + return nil +} + +// Convert_config_Plugins_To_v1beta3_Plugins is an autogenerated conversion function. +func Convert_config_Plugins_To_v1beta3_Plugins(in *config.Plugins, out *v1beta3.Plugins, s conversion.Scope) error { + return autoConvert_config_Plugins_To_v1beta3_Plugins(in, out, s) +} + +func autoConvert_v1beta3_PodTopologySpreadArgs_To_config_PodTopologySpreadArgs(in *v1beta3.PodTopologySpreadArgs, out *config.PodTopologySpreadArgs, s conversion.Scope) error { + out.DefaultConstraints = *(*[]corev1.TopologySpreadConstraint)(unsafe.Pointer(&in.DefaultConstraints)) + out.DefaultingType = config.PodTopologySpreadConstraintsDefaulting(in.DefaultingType) + return nil +} + +// Convert_v1beta3_PodTopologySpreadArgs_To_config_PodTopologySpreadArgs is an autogenerated conversion function. +func Convert_v1beta3_PodTopologySpreadArgs_To_config_PodTopologySpreadArgs(in *v1beta3.PodTopologySpreadArgs, out *config.PodTopologySpreadArgs, s conversion.Scope) error { + return autoConvert_v1beta3_PodTopologySpreadArgs_To_config_PodTopologySpreadArgs(in, out, s) +} + +func autoConvert_config_PodTopologySpreadArgs_To_v1beta3_PodTopologySpreadArgs(in *config.PodTopologySpreadArgs, out *v1beta3.PodTopologySpreadArgs, s conversion.Scope) error { + out.DefaultConstraints = *(*[]corev1.TopologySpreadConstraint)(unsafe.Pointer(&in.DefaultConstraints)) + out.DefaultingType = v1beta3.PodTopologySpreadConstraintsDefaulting(in.DefaultingType) + return nil +} + +// Convert_config_PodTopologySpreadArgs_To_v1beta3_PodTopologySpreadArgs is an autogenerated conversion function. +func Convert_config_PodTopologySpreadArgs_To_v1beta3_PodTopologySpreadArgs(in *config.PodTopologySpreadArgs, out *v1beta3.PodTopologySpreadArgs, s conversion.Scope) error { + return autoConvert_config_PodTopologySpreadArgs_To_v1beta3_PodTopologySpreadArgs(in, out, s) +} + +func autoConvert_v1beta3_RequestedToCapacityRatioParam_To_config_RequestedToCapacityRatioParam(in *v1beta3.RequestedToCapacityRatioParam, out *config.RequestedToCapacityRatioParam, s conversion.Scope) error { + out.Shape = *(*[]config.UtilizationShapePoint)(unsafe.Pointer(&in.Shape)) + return nil +} + +// Convert_v1beta3_RequestedToCapacityRatioParam_To_config_RequestedToCapacityRatioParam is an autogenerated conversion function. +func Convert_v1beta3_RequestedToCapacityRatioParam_To_config_RequestedToCapacityRatioParam(in *v1beta3.RequestedToCapacityRatioParam, out *config.RequestedToCapacityRatioParam, s conversion.Scope) error { + return autoConvert_v1beta3_RequestedToCapacityRatioParam_To_config_RequestedToCapacityRatioParam(in, out, s) +} + +func autoConvert_config_RequestedToCapacityRatioParam_To_v1beta3_RequestedToCapacityRatioParam(in *config.RequestedToCapacityRatioParam, out *v1beta3.RequestedToCapacityRatioParam, s conversion.Scope) error { + out.Shape = *(*[]v1beta3.UtilizationShapePoint)(unsafe.Pointer(&in.Shape)) + return nil +} + +// Convert_config_RequestedToCapacityRatioParam_To_v1beta3_RequestedToCapacityRatioParam is an autogenerated conversion function. +func Convert_config_RequestedToCapacityRatioParam_To_v1beta3_RequestedToCapacityRatioParam(in *config.RequestedToCapacityRatioParam, out *v1beta3.RequestedToCapacityRatioParam, s conversion.Scope) error { + return autoConvert_config_RequestedToCapacityRatioParam_To_v1beta3_RequestedToCapacityRatioParam(in, out, s) +} + +func autoConvert_v1beta3_ResourceSpec_To_config_ResourceSpec(in *v1beta3.ResourceSpec, out *config.ResourceSpec, s conversion.Scope) error { + out.Name = in.Name + out.Weight = in.Weight + return nil +} + +// Convert_v1beta3_ResourceSpec_To_config_ResourceSpec is an autogenerated conversion function. +func Convert_v1beta3_ResourceSpec_To_config_ResourceSpec(in *v1beta3.ResourceSpec, out *config.ResourceSpec, s conversion.Scope) error { + return autoConvert_v1beta3_ResourceSpec_To_config_ResourceSpec(in, out, s) +} + +func autoConvert_config_ResourceSpec_To_v1beta3_ResourceSpec(in *config.ResourceSpec, out *v1beta3.ResourceSpec, s conversion.Scope) error { + out.Name = in.Name + out.Weight = in.Weight + return nil +} + +// Convert_config_ResourceSpec_To_v1beta3_ResourceSpec is an autogenerated conversion function. +func Convert_config_ResourceSpec_To_v1beta3_ResourceSpec(in *config.ResourceSpec, out *v1beta3.ResourceSpec, s conversion.Scope) error { + return autoConvert_config_ResourceSpec_To_v1beta3_ResourceSpec(in, out, s) +} + +func autoConvert_v1beta3_ScoringStrategy_To_config_ScoringStrategy(in *v1beta3.ScoringStrategy, out *config.ScoringStrategy, s conversion.Scope) error { + out.Type = config.ScoringStrategyType(in.Type) + out.Resources = *(*[]config.ResourceSpec)(unsafe.Pointer(&in.Resources)) + out.RequestedToCapacityRatio = (*config.RequestedToCapacityRatioParam)(unsafe.Pointer(in.RequestedToCapacityRatio)) + return nil +} + +// Convert_v1beta3_ScoringStrategy_To_config_ScoringStrategy is an autogenerated conversion function. +func Convert_v1beta3_ScoringStrategy_To_config_ScoringStrategy(in *v1beta3.ScoringStrategy, out *config.ScoringStrategy, s conversion.Scope) error { + return autoConvert_v1beta3_ScoringStrategy_To_config_ScoringStrategy(in, out, s) +} + +func autoConvert_config_ScoringStrategy_To_v1beta3_ScoringStrategy(in *config.ScoringStrategy, out *v1beta3.ScoringStrategy, s conversion.Scope) error { + out.Type = v1beta3.ScoringStrategyType(in.Type) + out.Resources = *(*[]v1beta3.ResourceSpec)(unsafe.Pointer(&in.Resources)) + out.RequestedToCapacityRatio = (*v1beta3.RequestedToCapacityRatioParam)(unsafe.Pointer(in.RequestedToCapacityRatio)) + return nil +} + +// Convert_config_ScoringStrategy_To_v1beta3_ScoringStrategy is an autogenerated conversion function. +func Convert_config_ScoringStrategy_To_v1beta3_ScoringStrategy(in *config.ScoringStrategy, out *v1beta3.ScoringStrategy, s conversion.Scope) error { + return autoConvert_config_ScoringStrategy_To_v1beta3_ScoringStrategy(in, out, s) +} + +func autoConvert_v1beta3_UtilizationShapePoint_To_config_UtilizationShapePoint(in *v1beta3.UtilizationShapePoint, out *config.UtilizationShapePoint, s conversion.Scope) error { + out.Utilization = in.Utilization + out.Score = in.Score + return nil +} + +// Convert_v1beta3_UtilizationShapePoint_To_config_UtilizationShapePoint is an autogenerated conversion function. +func Convert_v1beta3_UtilizationShapePoint_To_config_UtilizationShapePoint(in *v1beta3.UtilizationShapePoint, out *config.UtilizationShapePoint, s conversion.Scope) error { + return autoConvert_v1beta3_UtilizationShapePoint_To_config_UtilizationShapePoint(in, out, s) +} + +func autoConvert_config_UtilizationShapePoint_To_v1beta3_UtilizationShapePoint(in *config.UtilizationShapePoint, out *v1beta3.UtilizationShapePoint, s conversion.Scope) error { + out.Utilization = in.Utilization + out.Score = in.Score + return nil +} + +// Convert_config_UtilizationShapePoint_To_v1beta3_UtilizationShapePoint is an autogenerated conversion function. +func Convert_config_UtilizationShapePoint_To_v1beta3_UtilizationShapePoint(in *config.UtilizationShapePoint, out *v1beta3.UtilizationShapePoint, s conversion.Scope) error { + return autoConvert_config_UtilizationShapePoint_To_v1beta3_UtilizationShapePoint(in, out, s) +} + +func autoConvert_v1beta3_VolumeBindingArgs_To_config_VolumeBindingArgs(in *v1beta3.VolumeBindingArgs, out *config.VolumeBindingArgs, s conversion.Scope) error { + if err := v1.Convert_Pointer_int64_To_int64(&in.BindTimeoutSeconds, &out.BindTimeoutSeconds, s); err != nil { + return err + } + out.Shape = *(*[]config.UtilizationShapePoint)(unsafe.Pointer(&in.Shape)) + return nil +} + +// Convert_v1beta3_VolumeBindingArgs_To_config_VolumeBindingArgs is an autogenerated conversion function. +func Convert_v1beta3_VolumeBindingArgs_To_config_VolumeBindingArgs(in *v1beta3.VolumeBindingArgs, out *config.VolumeBindingArgs, s conversion.Scope) error { + return autoConvert_v1beta3_VolumeBindingArgs_To_config_VolumeBindingArgs(in, out, s) +} + +func autoConvert_config_VolumeBindingArgs_To_v1beta3_VolumeBindingArgs(in *config.VolumeBindingArgs, out *v1beta3.VolumeBindingArgs, s conversion.Scope) error { + if err := v1.Convert_int64_To_Pointer_int64(&in.BindTimeoutSeconds, &out.BindTimeoutSeconds, s); err != nil { + return err + } + out.Shape = *(*[]v1beta3.UtilizationShapePoint)(unsafe.Pointer(&in.Shape)) + return nil +} + +// Convert_config_VolumeBindingArgs_To_v1beta3_VolumeBindingArgs is an autogenerated conversion function. +func Convert_config_VolumeBindingArgs_To_v1beta3_VolumeBindingArgs(in *config.VolumeBindingArgs, out *v1beta3.VolumeBindingArgs, s conversion.Scope) error { + return autoConvert_config_VolumeBindingArgs_To_v1beta3_VolumeBindingArgs(in, out, s) +} diff --git a/pkg/scheduler/apis/config/v1beta3/zz_generated.deepcopy.go b/pkg/scheduler/apis/config/v1beta3/zz_generated.deepcopy.go new file mode 100644 index 00000000000..e735e37dbb1 --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/zz_generated.deepcopy.go @@ -0,0 +1,22 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1beta3 diff --git a/pkg/scheduler/apis/config/v1beta3/zz_generated.defaults.go b/pkg/scheduler/apis/config/v1beta3/zz_generated.defaults.go new file mode 100644 index 00000000000..3c28679f62f --- /dev/null +++ b/pkg/scheduler/apis/config/v1beta3/zz_generated.defaults.go @@ -0,0 +1,73 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by defaulter-gen. DO NOT EDIT. + +package v1beta3 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + v1beta3 "k8s.io/kube-scheduler/config/v1beta3" +) + +// RegisterDefaults adds defaulters functions to the given scheme. +// Public to allow building arbitrary schemes. +// All generated defaulters are covering - they call all nested defaulters. +func RegisterDefaults(scheme *runtime.Scheme) error { + scheme.AddTypeDefaultingFunc(&v1beta3.DefaultPreemptionArgs{}, func(obj interface{}) { SetObjectDefaults_DefaultPreemptionArgs(obj.(*v1beta3.DefaultPreemptionArgs)) }) + scheme.AddTypeDefaultingFunc(&v1beta3.InterPodAffinityArgs{}, func(obj interface{}) { SetObjectDefaults_InterPodAffinityArgs(obj.(*v1beta3.InterPodAffinityArgs)) }) + scheme.AddTypeDefaultingFunc(&v1beta3.KubeSchedulerConfiguration{}, func(obj interface{}) { + SetObjectDefaults_KubeSchedulerConfiguration(obj.(*v1beta3.KubeSchedulerConfiguration)) + }) + scheme.AddTypeDefaultingFunc(&v1beta3.NodeResourcesBalancedAllocationArgs{}, func(obj interface{}) { + SetObjectDefaults_NodeResourcesBalancedAllocationArgs(obj.(*v1beta3.NodeResourcesBalancedAllocationArgs)) + }) + scheme.AddTypeDefaultingFunc(&v1beta3.NodeResourcesFitArgs{}, func(obj interface{}) { SetObjectDefaults_NodeResourcesFitArgs(obj.(*v1beta3.NodeResourcesFitArgs)) }) + scheme.AddTypeDefaultingFunc(&v1beta3.PodTopologySpreadArgs{}, func(obj interface{}) { SetObjectDefaults_PodTopologySpreadArgs(obj.(*v1beta3.PodTopologySpreadArgs)) }) + scheme.AddTypeDefaultingFunc(&v1beta3.VolumeBindingArgs{}, func(obj interface{}) { SetObjectDefaults_VolumeBindingArgs(obj.(*v1beta3.VolumeBindingArgs)) }) + return nil +} + +func SetObjectDefaults_DefaultPreemptionArgs(in *v1beta3.DefaultPreemptionArgs) { + SetDefaults_DefaultPreemptionArgs(in) +} + +func SetObjectDefaults_InterPodAffinityArgs(in *v1beta3.InterPodAffinityArgs) { + SetDefaults_InterPodAffinityArgs(in) +} + +func SetObjectDefaults_KubeSchedulerConfiguration(in *v1beta3.KubeSchedulerConfiguration) { + SetDefaults_KubeSchedulerConfiguration(in) +} + +func SetObjectDefaults_NodeResourcesBalancedAllocationArgs(in *v1beta3.NodeResourcesBalancedAllocationArgs) { + SetDefaults_NodeResourcesBalancedAllocationArgs(in) +} + +func SetObjectDefaults_NodeResourcesFitArgs(in *v1beta3.NodeResourcesFitArgs) { + SetDefaults_NodeResourcesFitArgs(in) +} + +func SetObjectDefaults_PodTopologySpreadArgs(in *v1beta3.PodTopologySpreadArgs) { + SetDefaults_PodTopologySpreadArgs(in) +} + +func SetObjectDefaults_VolumeBindingArgs(in *v1beta3.VolumeBindingArgs) { + SetDefaults_VolumeBindingArgs(in) +}