From 7c8a151faaf044cb0f40ef77d6d9ecf18993af3d Mon Sep 17 00:00:00 2001 From: ialidzhikov Date: Sun, 14 Aug 2022 19:14:01 +0300 Subject: [PATCH] pkg/scheduler: Replace deprecated func usage from the `k8s.io/utils/pointer` pkg --- .../apis/config/scheme/scheme_test.go | 12 +- .../apis/config/v1beta2/default_plugins.go | 16 +-- .../config/v1beta2/default_plugins_test.go | 38 +++--- pkg/scheduler/apis/config/v1beta2/defaults.go | 18 +-- .../apis/config/v1beta2/defaults_test.go | 108 +++++++++--------- .../config/v1beta3/default_plugins_test.go | 24 ++-- pkg/scheduler/apis/config/v1beta3/defaults.go | 16 +-- .../apis/config/v1beta3/defaults_test.go | 108 +++++++++--------- .../plugins/nodevolumelimits/csi_test.go | 4 +- .../plugins/nodevolumelimits/non_csi_test.go | 6 +- .../plugins/podtopologyspread/scoring_test.go | 38 +++--- .../selectorspread/selector_spread_test.go | 2 +- .../plugins/volumebinding/test_utils.go | 2 +- pkg/scheduler/schedule_one_test.go | 2 +- pkg/scheduler/testing/wrappers.go | 2 +- 15 files changed, 198 insertions(+), 198 deletions(-) diff --git a/pkg/scheduler/apis/config/scheme/scheme_test.go b/pkg/scheduler/apis/config/scheme/scheme_test.go index 8ff33d84ed3..3d934c3a160 100644 --- a/pkg/scheduler/apis/config/scheme/scheme_test.go +++ b/pkg/scheduler/apis/config/scheme/scheme_test.go @@ -1109,7 +1109,7 @@ func TestCodecsEncodePluginConfig(t *testing.T) { Name: "InterPodAffinity", Args: runtime.RawExtension{ Object: &v1beta2.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(5), + HardPodAffinityWeight: pointer.Int32(5), }, }, }, @@ -1117,7 +1117,7 @@ func TestCodecsEncodePluginConfig(t *testing.T) { Name: "VolumeBinding", Args: runtime.RawExtension{ Object: &v1beta2.VolumeBindingArgs{ - BindTimeoutSeconds: pointer.Int64Ptr(300), + BindTimeoutSeconds: pointer.Int64(300), Shape: []v1beta2.UtilizationShapePoint{ { Utilization: 0, @@ -1330,7 +1330,7 @@ profiles: Name: "InterPodAffinity", Args: runtime.RawExtension{ Object: &v1beta3.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(5), + HardPodAffinityWeight: pointer.Int32(5), }, }, }, @@ -1338,7 +1338,7 @@ profiles: Name: "VolumeBinding", Args: runtime.RawExtension{ Object: &v1beta2.VolumeBindingArgs{ - BindTimeoutSeconds: pointer.Int64Ptr(300), + BindTimeoutSeconds: pointer.Int64(300), Shape: []v1beta2.UtilizationShapePoint{ { Utilization: 0, @@ -1549,7 +1549,7 @@ profiles: Name: "InterPodAffinity", Args: runtime.RawExtension{ Object: &v1.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(5), + HardPodAffinityWeight: pointer.Int32(5), }, }, }, @@ -1557,7 +1557,7 @@ profiles: Name: "VolumeBinding", Args: runtime.RawExtension{ Object: &v1.VolumeBindingArgs{ - BindTimeoutSeconds: pointer.Int64Ptr(300), + BindTimeoutSeconds: pointer.Int64(300), Shape: []v1.UtilizationShapePoint{ { Utilization: 0, diff --git a/pkg/scheduler/apis/config/v1beta2/default_plugins.go b/pkg/scheduler/apis/config/v1beta2/default_plugins.go index 0eb8af06e46..5b2a2017bb6 100644 --- a/pkg/scheduler/apis/config/v1beta2/default_plugins.go +++ b/pkg/scheduler/apis/config/v1beta2/default_plugins.go @@ -79,16 +79,16 @@ func getDefaultPlugins() *v1beta2.Plugins { }, Score: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ - {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32Ptr(1)}, - {Name: names.ImageLocality, Weight: pointer.Int32Ptr(1)}, - {Name: names.InterPodAffinity, Weight: pointer.Int32Ptr(1)}, - {Name: names.NodeResourcesFit, Weight: pointer.Int32Ptr(1)}, - {Name: names.NodeAffinity, Weight: pointer.Int32Ptr(1)}, + {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32(1)}, + {Name: names.ImageLocality, Weight: pointer.Int32(1)}, + {Name: names.InterPodAffinity, Weight: pointer.Int32(1)}, + {Name: names.NodeResourcesFit, Weight: pointer.Int32(1)}, + {Name: names.NodeAffinity, Weight: pointer.Int32(1)}, // 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)}, - {Name: names.TaintToleration, Weight: pointer.Int32Ptr(1)}, + {Name: names.PodTopologySpread, Weight: pointer.Int32(2)}, + {Name: names.TaintToleration, Weight: pointer.Int32(1)}, }, }, Reserve: v1beta2.PluginSet{ @@ -114,7 +114,7 @@ func getDefaultPlugins() *v1beta2.Plugins { func applyFeatureGates(config *v1beta2.Plugins) { if utilfeature.DefaultFeatureGate.Enabled(features.VolumeCapacityPriority) { - config.Score.Enabled = append(config.Score.Enabled, v1beta2.Plugin{Name: names.VolumeBinding, Weight: pointer.Int32Ptr(1)}) + config.Score.Enabled = append(config.Score.Enabled, v1beta2.Plugin{Name: names.VolumeBinding, Weight: pointer.Int32(1)}) } } diff --git a/pkg/scheduler/apis/config/v1beta2/default_plugins_test.go b/pkg/scheduler/apis/config/v1beta2/default_plugins_test.go index 6909fc74041..27f6e53db44 100644 --- a/pkg/scheduler/apis/config/v1beta2/default_plugins_test.go +++ b/pkg/scheduler/apis/config/v1beta2/default_plugins_test.go @@ -87,13 +87,13 @@ func TestApplyFeatureGates(t *testing.T) { }, Score: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ - {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32Ptr(1)}, - {Name: names.ImageLocality, Weight: pointer.Int32Ptr(1)}, - {Name: names.InterPodAffinity, Weight: pointer.Int32Ptr(1)}, - {Name: names.NodeResourcesFit, Weight: pointer.Int32Ptr(1)}, - {Name: names.NodeAffinity, Weight: pointer.Int32Ptr(1)}, - {Name: names.PodTopologySpread, Weight: pointer.Int32Ptr(2)}, - {Name: names.TaintToleration, Weight: pointer.Int32Ptr(1)}, + {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32(1)}, + {Name: names.ImageLocality, Weight: pointer.Int32(1)}, + {Name: names.InterPodAffinity, Weight: pointer.Int32(1)}, + {Name: names.NodeResourcesFit, Weight: pointer.Int32(1)}, + {Name: names.NodeAffinity, Weight: pointer.Int32(1)}, + {Name: names.PodTopologySpread, Weight: pointer.Int32(2)}, + {Name: names.TaintToleration, Weight: pointer.Int32(1)}, }, }, Reserve: v1beta2.PluginSet{ @@ -281,8 +281,8 @@ func TestMergePlugins(t *testing.T) { customPlugins: &v1beta2.Plugins{ Filter: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ - {Name: "Plugin1", Weight: pointer.Int32Ptr(2)}, - {Name: "Plugin3", Weight: pointer.Int32Ptr(3)}, + {Name: "Plugin1", Weight: pointer.Int32(2)}, + {Name: "Plugin3", Weight: pointer.Int32(3)}, }, }, }, @@ -298,9 +298,9 @@ func TestMergePlugins(t *testing.T) { expectedPlugins: &v1beta2.Plugins{ Filter: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ - {Name: "Plugin1", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin1", Weight: pointer.Int32(2)}, {Name: "Plugin2"}, - {Name: "Plugin3", Weight: pointer.Int32Ptr(3)}, + {Name: "Plugin3", Weight: pointer.Int32(3)}, }, }, }, @@ -310,8 +310,8 @@ func TestMergePlugins(t *testing.T) { customPlugins: &v1beta2.Plugins{ Filter: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ - {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, - {Name: "Plugin1", Weight: pointer.Int32Ptr(1)}, + {Name: "Plugin2", Weight: pointer.Int32(2)}, + {Name: "Plugin1", Weight: pointer.Int32(1)}, }, }, }, @@ -327,8 +327,8 @@ func TestMergePlugins(t *testing.T) { expectedPlugins: &v1beta2.Plugins{ Filter: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ - {Name: "Plugin1", Weight: pointer.Int32Ptr(1)}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin1", Weight: pointer.Int32(1)}, + {Name: "Plugin2", Weight: pointer.Int32(2)}, {Name: "Plugin3"}, }, }, @@ -340,9 +340,9 @@ func TestMergePlugins(t *testing.T) { Filter: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ {Name: "Plugin1"}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin2", Weight: pointer.Int32(2)}, {Name: "Plugin3"}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(4)}, + {Name: "Plugin2", Weight: pointer.Int32(4)}, }, }, }, @@ -359,9 +359,9 @@ func TestMergePlugins(t *testing.T) { Filter: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ {Name: "Plugin1"}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(4)}, + {Name: "Plugin2", Weight: pointer.Int32(4)}, {Name: "Plugin3"}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin2", Weight: pointer.Int32(2)}, }, }, }, diff --git a/pkg/scheduler/apis/config/v1beta2/defaults.go b/pkg/scheduler/apis/config/v1beta2/defaults.go index 1d6fa24166d..1bf12080673 100644 --- a/pkg/scheduler/apis/config/v1beta2/defaults.go +++ b/pkg/scheduler/apis/config/v1beta2/defaults.go @@ -102,7 +102,7 @@ func setDefaults_KubeSchedulerProfile(prof *v1beta2.KubeSchedulerProfile) { // SetDefaults_KubeSchedulerConfiguration sets additional defaults func SetDefaults_KubeSchedulerConfiguration(obj *v1beta2.KubeSchedulerConfiguration) { if obj.Parallelism == nil { - obj.Parallelism = pointer.Int32Ptr(16) + obj.Parallelism = pointer.Int32(16) } if len(obj.Profiles) == 0 { @@ -111,7 +111,7 @@ func SetDefaults_KubeSchedulerConfiguration(obj *v1beta2.KubeSchedulerConfigurat // 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) + obj.Profiles[0].SchedulerName = pointer.String(v1.DefaultSchedulerName) } // Add the default set of plugins and apply the configuration. @@ -121,7 +121,7 @@ func SetDefaults_KubeSchedulerConfiguration(obj *v1beta2.KubeSchedulerConfigurat } if obj.PercentageOfNodesToScore == nil { - obj.PercentageOfNodesToScore = pointer.Int32Ptr(config.DefaultPercentageOfNodesToScore) + obj.PercentageOfNodesToScore = pointer.Int32(config.DefaultPercentageOfNodesToScore) } if len(obj.LeaderElection.ResourceLock) == 0 { @@ -161,33 +161,33 @@ func SetDefaults_KubeSchedulerConfiguration(obj *v1beta2.KubeSchedulerConfigurat // Enable profiling by default in the scheduler if obj.EnableProfiling == nil { - obj.EnableProfiling = pointer.BoolPtr(true) + obj.EnableProfiling = pointer.Bool(true) } // Enable contention profiling by default if profiling is enabled if *obj.EnableProfiling && obj.EnableContentionProfiling == nil { - obj.EnableContentionProfiling = pointer.BoolPtr(true) + obj.EnableContentionProfiling = pointer.Bool(true) } } func SetDefaults_DefaultPreemptionArgs(obj *v1beta2.DefaultPreemptionArgs) { if obj.MinCandidateNodesPercentage == nil { - obj.MinCandidateNodesPercentage = pointer.Int32Ptr(10) + obj.MinCandidateNodesPercentage = pointer.Int32(10) } if obj.MinCandidateNodesAbsolute == nil { - obj.MinCandidateNodesAbsolute = pointer.Int32Ptr(100) + obj.MinCandidateNodesAbsolute = pointer.Int32(100) } } func SetDefaults_InterPodAffinityArgs(obj *v1beta2.InterPodAffinityArgs) { if obj.HardPodAffinityWeight == nil { - obj.HardPodAffinityWeight = pointer.Int32Ptr(1) + obj.HardPodAffinityWeight = pointer.Int32(1) } } func SetDefaults_VolumeBindingArgs(obj *v1beta2.VolumeBindingArgs) { if obj.BindTimeoutSeconds == nil { - obj.BindTimeoutSeconds = pointer.Int64Ptr(600) + obj.BindTimeoutSeconds = pointer.Int64(600) } if len(obj.Shape) == 0 && feature.DefaultFeatureGate.Enabled(features.VolumeCapacityPriority) { obj.Shape = []v1beta2.UtilizationShapePoint{ diff --git a/pkg/scheduler/apis/config/v1beta2/defaults_test.go b/pkg/scheduler/apis/config/v1beta2/defaults_test.go index d25b5309365..08085cf2896 100644 --- a/pkg/scheduler/apis/config/v1beta2/defaults_test.go +++ b/pkg/scheduler/apis/config/v1beta2/defaults_test.go @@ -45,8 +45,8 @@ var pluginConfigs = []v1beta2.PluginConfig{ Kind: "DefaultPreemptionArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta2", }, - MinCandidateNodesPercentage: pointer.Int32Ptr(10), - MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + MinCandidateNodesPercentage: pointer.Int32(10), + MinCandidateNodesAbsolute: pointer.Int32(100), }}, }, { @@ -57,7 +57,7 @@ var pluginConfigs = []v1beta2.PluginConfig{ Kind: "InterPodAffinityArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta2", }, - HardPodAffinityWeight: pointer.Int32Ptr(1), + HardPodAffinityWeight: pointer.Int32(1), }}, }, { @@ -109,7 +109,7 @@ var pluginConfigs = []v1beta2.PluginConfig{ Kind: "VolumeBindingArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta2", }, - BindTimeoutSeconds: pointer.Int64Ptr(600), + BindTimeoutSeconds: pointer.Int64(600), }}, }, } @@ -125,13 +125,13 @@ func TestSchedulerDefaults(t *testing.T) { name: "empty config", config: &v1beta2.KubeSchedulerConfiguration{}, expected: &v1beta2.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ EnableProfiling: &enable, EnableContentionProfiling: &enable, }, LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), + LeaderElect: pointer.Bool(true), LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, @@ -144,14 +144,14 @@ func TestSchedulerDefaults(t *testing.T) { Burst: 100, ContentType: "application/vnd.kubernetes.protobuf", }, - PercentageOfNodesToScore: pointer.Int32Ptr(0), - PodInitialBackoffSeconds: pointer.Int64Ptr(1), - PodMaxBackoffSeconds: pointer.Int64Ptr(10), + PercentageOfNodesToScore: pointer.Int32(0), + PodInitialBackoffSeconds: pointer.Int64(1), + PodMaxBackoffSeconds: pointer.Int64(10), Profiles: []v1beta2.KubeSchedulerProfile{ { Plugins: getDefaultPlugins(), PluginConfig: pluginConfigs, - SchedulerName: pointer.StringPtr("default-scheduler"), + SchedulerName: pointer.String("default-scheduler"), }, }, }, @@ -162,13 +162,13 @@ func TestSchedulerDefaults(t *testing.T) { Profiles: []v1beta2.KubeSchedulerProfile{{}}, }, expected: &v1beta2.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ EnableProfiling: &enable, EnableContentionProfiling: &enable, }, LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), + LeaderElect: pointer.Bool(true), LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, @@ -181,12 +181,12 @@ func TestSchedulerDefaults(t *testing.T) { Burst: 100, ContentType: "application/vnd.kubernetes.protobuf", }, - PercentageOfNodesToScore: pointer.Int32Ptr(0), - PodInitialBackoffSeconds: pointer.Int64Ptr(1), - PodMaxBackoffSeconds: pointer.Int64Ptr(10), + PercentageOfNodesToScore: pointer.Int32(0), + PodInitialBackoffSeconds: pointer.Int64(1), + PodMaxBackoffSeconds: pointer.Int64(10), Profiles: []v1beta2.KubeSchedulerProfile{ { - SchedulerName: pointer.StringPtr("default-scheduler"), + SchedulerName: pointer.String("default-scheduler"), Plugins: getDefaultPlugins(), PluginConfig: pluginConfigs}, }, @@ -195,7 +195,7 @@ func TestSchedulerDefaults(t *testing.T) { { name: "two profiles", config: &v1beta2.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), Profiles: []v1beta2.KubeSchedulerProfile{ { PluginConfig: []v1beta2.PluginConfig{ @@ -203,7 +203,7 @@ func TestSchedulerDefaults(t *testing.T) { }, }, { - SchedulerName: pointer.StringPtr("custom-scheduler"), + SchedulerName: pointer.String("custom-scheduler"), Plugins: &v1beta2.Plugins{ Bind: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ @@ -218,13 +218,13 @@ func TestSchedulerDefaults(t *testing.T) { }, }, expected: &v1beta2.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ EnableProfiling: &enable, EnableContentionProfiling: &enable, }, LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), + LeaderElect: pointer.Bool(true), LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, @@ -237,9 +237,9 @@ func TestSchedulerDefaults(t *testing.T) { Burst: 100, ContentType: "application/vnd.kubernetes.protobuf", }, - PercentageOfNodesToScore: pointer.Int32Ptr(0), - PodInitialBackoffSeconds: pointer.Int64Ptr(1), - PodMaxBackoffSeconds: pointer.Int64Ptr(10), + PercentageOfNodesToScore: pointer.Int32(0), + PodInitialBackoffSeconds: pointer.Int64(1), + PodMaxBackoffSeconds: pointer.Int64(10), Profiles: []v1beta2.KubeSchedulerProfile{ { Plugins: getDefaultPlugins(), @@ -253,8 +253,8 @@ func TestSchedulerDefaults(t *testing.T) { Kind: "DefaultPreemptionArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta2", }, - MinCandidateNodesPercentage: pointer.Int32Ptr(10), - MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + MinCandidateNodesPercentage: pointer.Int32(10), + MinCandidateNodesAbsolute: pointer.Int32(100), }}, }, { @@ -265,7 +265,7 @@ func TestSchedulerDefaults(t *testing.T) { Kind: "InterPodAffinityArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta2", }, - HardPodAffinityWeight: pointer.Int32Ptr(1), + HardPodAffinityWeight: pointer.Int32(1), }}, }, { @@ -317,13 +317,13 @@ func TestSchedulerDefaults(t *testing.T) { Kind: "VolumeBindingArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta2", }, - BindTimeoutSeconds: pointer.Int64Ptr(600), + BindTimeoutSeconds: pointer.Int64(600), }}, }, }, }, { - SchedulerName: pointer.StringPtr("custom-scheduler"), + SchedulerName: pointer.String("custom-scheduler"), Plugins: &v1beta2.Plugins{ QueueSort: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ @@ -375,13 +375,13 @@ func TestSchedulerDefaults(t *testing.T) { }, Score: v1beta2.PluginSet{ Enabled: []v1beta2.Plugin{ - {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32Ptr(1)}, - {Name: names.ImageLocality, Weight: pointer.Int32Ptr(1)}, - {Name: names.InterPodAffinity, Weight: pointer.Int32Ptr(1)}, - {Name: names.NodeResourcesFit, Weight: pointer.Int32Ptr(1)}, - {Name: names.NodeAffinity, Weight: pointer.Int32Ptr(1)}, - {Name: names.PodTopologySpread, Weight: pointer.Int32Ptr(2)}, - {Name: names.TaintToleration, Weight: pointer.Int32Ptr(1)}, + {Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32(1)}, + {Name: names.ImageLocality, Weight: pointer.Int32(1)}, + {Name: names.InterPodAffinity, Weight: pointer.Int32(1)}, + {Name: names.NodeResourcesFit, Weight: pointer.Int32(1)}, + {Name: names.NodeAffinity, Weight: pointer.Int32(1)}, + {Name: names.PodTopologySpread, Weight: pointer.Int32(2)}, + {Name: names.TaintToleration, Weight: pointer.Int32(1)}, }, }, Reserve: v1beta2.PluginSet{ @@ -408,16 +408,16 @@ func TestSchedulerDefaults(t *testing.T) { { name: "set non default parallelism", config: &v1beta2.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(8), + Parallelism: pointer.Int32(8), }, expected: &v1beta2.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(8), + Parallelism: pointer.Int32(8), DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ EnableProfiling: &enable, EnableContentionProfiling: &enable, }, LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), + LeaderElect: pointer.Bool(true), LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, @@ -430,14 +430,14 @@ func TestSchedulerDefaults(t *testing.T) { Burst: 100, ContentType: "application/vnd.kubernetes.protobuf", }, - PercentageOfNodesToScore: pointer.Int32Ptr(0), - PodInitialBackoffSeconds: pointer.Int64Ptr(1), - PodMaxBackoffSeconds: pointer.Int64Ptr(10), + PercentageOfNodesToScore: pointer.Int32(0), + PodInitialBackoffSeconds: pointer.Int64(1), + PodMaxBackoffSeconds: pointer.Int64(10), Profiles: []v1beta2.KubeSchedulerProfile{ { Plugins: getDefaultPlugins(), PluginConfig: pluginConfigs, - SchedulerName: pointer.StringPtr("default-scheduler"), + SchedulerName: pointer.String("default-scheduler"), }, }, }, @@ -464,43 +464,43 @@ func TestPluginArgsDefaults(t *testing.T) { name: "DefaultPreemptionArgs empty", in: &v1beta2.DefaultPreemptionArgs{}, want: &v1beta2.DefaultPreemptionArgs{ - MinCandidateNodesPercentage: pointer.Int32Ptr(10), - MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + MinCandidateNodesPercentage: pointer.Int32(10), + MinCandidateNodesAbsolute: pointer.Int32(100), }, }, { name: "DefaultPreemptionArgs with value", in: &v1beta2.DefaultPreemptionArgs{ - MinCandidateNodesPercentage: pointer.Int32Ptr(50), + MinCandidateNodesPercentage: pointer.Int32(50), }, want: &v1beta2.DefaultPreemptionArgs{ - MinCandidateNodesPercentage: pointer.Int32Ptr(50), - MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + MinCandidateNodesPercentage: pointer.Int32(50), + MinCandidateNodesAbsolute: pointer.Int32(100), }, }, { name: "InterPodAffinityArgs empty", in: &v1beta2.InterPodAffinityArgs{}, want: &v1beta2.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(1), + HardPodAffinityWeight: pointer.Int32(1), }, }, { name: "InterPodAffinityArgs explicit 0", in: &v1beta2.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(0), + HardPodAffinityWeight: pointer.Int32(0), }, want: &v1beta2.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(0), + HardPodAffinityWeight: pointer.Int32(0), }, }, { name: "InterPodAffinityArgs with value", in: &v1beta2.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(5), + HardPodAffinityWeight: pointer.Int32(5), }, want: &v1beta2.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(5), + HardPodAffinityWeight: pointer.Int32(5), }, }, { @@ -617,7 +617,7 @@ func TestPluginArgsDefaults(t *testing.T) { }, in: &v1beta2.VolumeBindingArgs{}, want: &v1beta2.VolumeBindingArgs{ - BindTimeoutSeconds: pointer.Int64Ptr(600), + BindTimeoutSeconds: pointer.Int64(600), }, }, { @@ -627,7 +627,7 @@ func TestPluginArgsDefaults(t *testing.T) { }, in: &v1beta2.VolumeBindingArgs{}, want: &v1beta2.VolumeBindingArgs{ - BindTimeoutSeconds: pointer.Int64Ptr(600), + BindTimeoutSeconds: pointer.Int64(600), Shape: []v1beta2.UtilizationShapePoint{ {Utilization: 0, Score: 0}, {Utilization: 100, Score: 10}, diff --git a/pkg/scheduler/apis/config/v1beta3/default_plugins_test.go b/pkg/scheduler/apis/config/v1beta3/default_plugins_test.go index 05d0a33d5d3..66e5f81235a 100644 --- a/pkg/scheduler/apis/config/v1beta3/default_plugins_test.go +++ b/pkg/scheduler/apis/config/v1beta3/default_plugins_test.go @@ -240,8 +240,8 @@ func TestMergePlugins(t *testing.T) { customPlugins: &v1beta3.Plugins{ Filter: v1beta3.PluginSet{ Enabled: []v1beta3.Plugin{ - {Name: "Plugin1", Weight: pointer.Int32Ptr(2)}, - {Name: "Plugin3", Weight: pointer.Int32Ptr(3)}, + {Name: "Plugin1", Weight: pointer.Int32(2)}, + {Name: "Plugin3", Weight: pointer.Int32(3)}, }, }, }, @@ -257,9 +257,9 @@ func TestMergePlugins(t *testing.T) { expectedPlugins: &v1beta3.Plugins{ Filter: v1beta3.PluginSet{ Enabled: []v1beta3.Plugin{ - {Name: "Plugin1", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin1", Weight: pointer.Int32(2)}, {Name: "Plugin2"}, - {Name: "Plugin3", Weight: pointer.Int32Ptr(3)}, + {Name: "Plugin3", Weight: pointer.Int32(3)}, }, }, }, @@ -269,8 +269,8 @@ func TestMergePlugins(t *testing.T) { customPlugins: &v1beta3.Plugins{ Filter: v1beta3.PluginSet{ Enabled: []v1beta3.Plugin{ - {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, - {Name: "Plugin1", Weight: pointer.Int32Ptr(1)}, + {Name: "Plugin2", Weight: pointer.Int32(2)}, + {Name: "Plugin1", Weight: pointer.Int32(1)}, }, }, }, @@ -286,8 +286,8 @@ func TestMergePlugins(t *testing.T) { expectedPlugins: &v1beta3.Plugins{ Filter: v1beta3.PluginSet{ Enabled: []v1beta3.Plugin{ - {Name: "Plugin1", Weight: pointer.Int32Ptr(1)}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin1", Weight: pointer.Int32(1)}, + {Name: "Plugin2", Weight: pointer.Int32(2)}, {Name: "Plugin3"}, }, }, @@ -299,9 +299,9 @@ func TestMergePlugins(t *testing.T) { Filter: v1beta3.PluginSet{ Enabled: []v1beta3.Plugin{ {Name: "Plugin1"}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin2", Weight: pointer.Int32(2)}, {Name: "Plugin3"}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(4)}, + {Name: "Plugin2", Weight: pointer.Int32(4)}, }, }, }, @@ -318,9 +318,9 @@ func TestMergePlugins(t *testing.T) { Filter: v1beta3.PluginSet{ Enabled: []v1beta3.Plugin{ {Name: "Plugin1"}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(4)}, + {Name: "Plugin2", Weight: pointer.Int32(4)}, {Name: "Plugin3"}, - {Name: "Plugin2", Weight: pointer.Int32Ptr(2)}, + {Name: "Plugin2", Weight: pointer.Int32(2)}, }, }, }, diff --git a/pkg/scheduler/apis/config/v1beta3/defaults.go b/pkg/scheduler/apis/config/v1beta3/defaults.go index 84552b5cbdc..b3816d36a00 100644 --- a/pkg/scheduler/apis/config/v1beta3/defaults.go +++ b/pkg/scheduler/apis/config/v1beta3/defaults.go @@ -102,7 +102,7 @@ func setDefaults_KubeSchedulerProfile(prof *v1beta3.KubeSchedulerProfile) { // SetDefaults_KubeSchedulerConfiguration sets additional defaults func SetDefaults_KubeSchedulerConfiguration(obj *v1beta3.KubeSchedulerConfiguration) { if obj.Parallelism == nil { - obj.Parallelism = pointer.Int32Ptr(16) + obj.Parallelism = pointer.Int32(16) } if len(obj.Profiles) == 0 { @@ -111,7 +111,7 @@ func SetDefaults_KubeSchedulerConfiguration(obj *v1beta3.KubeSchedulerConfigurat // 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) + obj.Profiles[0].SchedulerName = pointer.String(v1.DefaultSchedulerName) } // Add the default set of plugins and apply the configuration. @@ -162,33 +162,33 @@ func SetDefaults_KubeSchedulerConfiguration(obj *v1beta3.KubeSchedulerConfigurat // Enable profiling by default in the scheduler if obj.EnableProfiling == nil { - obj.EnableProfiling = pointer.BoolPtr(true) + obj.EnableProfiling = pointer.Bool(true) } // Enable contention profiling by default if profiling is enabled if *obj.EnableProfiling && obj.EnableContentionProfiling == nil { - obj.EnableContentionProfiling = pointer.BoolPtr(true) + obj.EnableContentionProfiling = pointer.Bool(true) } } func SetDefaults_DefaultPreemptionArgs(obj *v1beta3.DefaultPreemptionArgs) { if obj.MinCandidateNodesPercentage == nil { - obj.MinCandidateNodesPercentage = pointer.Int32Ptr(10) + obj.MinCandidateNodesPercentage = pointer.Int32(10) } if obj.MinCandidateNodesAbsolute == nil { - obj.MinCandidateNodesAbsolute = pointer.Int32Ptr(100) + obj.MinCandidateNodesAbsolute = pointer.Int32(100) } } func SetDefaults_InterPodAffinityArgs(obj *v1beta3.InterPodAffinityArgs) { if obj.HardPodAffinityWeight == nil { - obj.HardPodAffinityWeight = pointer.Int32Ptr(1) + obj.HardPodAffinityWeight = pointer.Int32(1) } } func SetDefaults_VolumeBindingArgs(obj *v1beta3.VolumeBindingArgs) { if obj.BindTimeoutSeconds == nil { - obj.BindTimeoutSeconds = pointer.Int64Ptr(600) + obj.BindTimeoutSeconds = pointer.Int64(600) } if len(obj.Shape) == 0 && feature.DefaultFeatureGate.Enabled(features.VolumeCapacityPriority) { obj.Shape = []v1beta3.UtilizationShapePoint{ diff --git a/pkg/scheduler/apis/config/v1beta3/defaults_test.go b/pkg/scheduler/apis/config/v1beta3/defaults_test.go index f1c2a0fa27a..beac99f530c 100644 --- a/pkg/scheduler/apis/config/v1beta3/defaults_test.go +++ b/pkg/scheduler/apis/config/v1beta3/defaults_test.go @@ -45,8 +45,8 @@ var pluginConfigs = []v1beta3.PluginConfig{ Kind: "DefaultPreemptionArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta3", }, - MinCandidateNodesPercentage: pointer.Int32Ptr(10), - MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + MinCandidateNodesPercentage: pointer.Int32(10), + MinCandidateNodesAbsolute: pointer.Int32(100), }}, }, { @@ -57,7 +57,7 @@ var pluginConfigs = []v1beta3.PluginConfig{ Kind: "InterPodAffinityArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta3", }, - HardPodAffinityWeight: pointer.Int32Ptr(1), + HardPodAffinityWeight: pointer.Int32(1), }}, }, { @@ -109,7 +109,7 @@ var pluginConfigs = []v1beta3.PluginConfig{ Kind: "VolumeBindingArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta3", }, - BindTimeoutSeconds: pointer.Int64Ptr(600), + BindTimeoutSeconds: pointer.Int64(600), }}, }, } @@ -125,13 +125,13 @@ func TestSchedulerDefaults(t *testing.T) { name: "empty config", config: &v1beta3.KubeSchedulerConfiguration{}, expected: &v1beta3.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ EnableProfiling: &enable, EnableContentionProfiling: &enable, }, LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), + LeaderElect: pointer.Bool(true), LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, @@ -144,14 +144,14 @@ func TestSchedulerDefaults(t *testing.T) { Burst: 100, ContentType: "application/vnd.kubernetes.protobuf", }, - PercentageOfNodesToScore: pointer.Int32Ptr(0), - PodInitialBackoffSeconds: pointer.Int64Ptr(1), - PodMaxBackoffSeconds: pointer.Int64Ptr(10), + PercentageOfNodesToScore: pointer.Int32(0), + PodInitialBackoffSeconds: pointer.Int64(1), + PodMaxBackoffSeconds: pointer.Int64(10), Profiles: []v1beta3.KubeSchedulerProfile{ { Plugins: getDefaultPlugins(), PluginConfig: pluginConfigs, - SchedulerName: pointer.StringPtr("default-scheduler"), + SchedulerName: pointer.String("default-scheduler"), }, }, }, @@ -162,13 +162,13 @@ func TestSchedulerDefaults(t *testing.T) { Profiles: []v1beta3.KubeSchedulerProfile{{}}, }, expected: &v1beta3.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ EnableProfiling: &enable, EnableContentionProfiling: &enable, }, LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), + LeaderElect: pointer.Bool(true), LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, @@ -181,12 +181,12 @@ func TestSchedulerDefaults(t *testing.T) { Burst: 100, ContentType: "application/vnd.kubernetes.protobuf", }, - PercentageOfNodesToScore: pointer.Int32Ptr(0), - PodInitialBackoffSeconds: pointer.Int64Ptr(1), - PodMaxBackoffSeconds: pointer.Int64Ptr(10), + PercentageOfNodesToScore: pointer.Int32(0), + PodInitialBackoffSeconds: pointer.Int64(1), + PodMaxBackoffSeconds: pointer.Int64(10), Profiles: []v1beta3.KubeSchedulerProfile{ { - SchedulerName: pointer.StringPtr("default-scheduler"), + SchedulerName: pointer.String("default-scheduler"), Plugins: getDefaultPlugins(), PluginConfig: pluginConfigs}, }, @@ -195,7 +195,7 @@ func TestSchedulerDefaults(t *testing.T) { { name: "two profiles", config: &v1beta3.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), Profiles: []v1beta3.KubeSchedulerProfile{ { PluginConfig: []v1beta3.PluginConfig{ @@ -203,7 +203,7 @@ func TestSchedulerDefaults(t *testing.T) { }, }, { - SchedulerName: pointer.StringPtr("custom-scheduler"), + SchedulerName: pointer.String("custom-scheduler"), Plugins: &v1beta3.Plugins{ Bind: v1beta3.PluginSet{ Enabled: []v1beta3.Plugin{ @@ -218,13 +218,13 @@ func TestSchedulerDefaults(t *testing.T) { }, }, expected: &v1beta3.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ EnableProfiling: &enable, EnableContentionProfiling: &enable, }, LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), + LeaderElect: pointer.Bool(true), LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, @@ -237,9 +237,9 @@ func TestSchedulerDefaults(t *testing.T) { Burst: 100, ContentType: "application/vnd.kubernetes.protobuf", }, - PercentageOfNodesToScore: pointer.Int32Ptr(0), - PodInitialBackoffSeconds: pointer.Int64Ptr(1), - PodMaxBackoffSeconds: pointer.Int64Ptr(10), + PercentageOfNodesToScore: pointer.Int32(0), + PodInitialBackoffSeconds: pointer.Int64(1), + PodMaxBackoffSeconds: pointer.Int64(10), Profiles: []v1beta3.KubeSchedulerProfile{ { Plugins: getDefaultPlugins(), @@ -253,8 +253,8 @@ func TestSchedulerDefaults(t *testing.T) { Kind: "DefaultPreemptionArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta3", }, - MinCandidateNodesPercentage: pointer.Int32Ptr(10), - MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + MinCandidateNodesPercentage: pointer.Int32(10), + MinCandidateNodesAbsolute: pointer.Int32(100), }}, }, { @@ -265,7 +265,7 @@ func TestSchedulerDefaults(t *testing.T) { Kind: "InterPodAffinityArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta3", }, - HardPodAffinityWeight: pointer.Int32Ptr(1), + HardPodAffinityWeight: pointer.Int32(1), }}, }, { @@ -317,13 +317,13 @@ func TestSchedulerDefaults(t *testing.T) { Kind: "VolumeBindingArgs", APIVersion: "kubescheduler.config.k8s.io/v1beta3", }, - BindTimeoutSeconds: pointer.Int64Ptr(600), + BindTimeoutSeconds: pointer.Int64(600), }}, }, }, }, { - SchedulerName: pointer.StringPtr("custom-scheduler"), + SchedulerName: pointer.String("custom-scheduler"), Plugins: &v1beta3.Plugins{ MultiPoint: v1beta3.PluginSet{ Enabled: []v1beta3.Plugin{ @@ -366,16 +366,16 @@ func TestSchedulerDefaults(t *testing.T) { { name: "Prallelism with no port", config: &v1beta3.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), }, expected: &v1beta3.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(16), + Parallelism: pointer.Int32(16), DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ EnableProfiling: &enable, EnableContentionProfiling: &enable, }, LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), + LeaderElect: pointer.Bool(true), LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, @@ -388,14 +388,14 @@ func TestSchedulerDefaults(t *testing.T) { Burst: 100, ContentType: "application/vnd.kubernetes.protobuf", }, - PercentageOfNodesToScore: pointer.Int32Ptr(0), - PodInitialBackoffSeconds: pointer.Int64Ptr(1), - PodMaxBackoffSeconds: pointer.Int64Ptr(10), + PercentageOfNodesToScore: pointer.Int32(0), + PodInitialBackoffSeconds: pointer.Int64(1), + PodMaxBackoffSeconds: pointer.Int64(10), Profiles: []v1beta3.KubeSchedulerProfile{ { Plugins: getDefaultPlugins(), PluginConfig: pluginConfigs, - SchedulerName: pointer.StringPtr("default-scheduler"), + SchedulerName: pointer.String("default-scheduler"), }, }, }, @@ -403,16 +403,16 @@ func TestSchedulerDefaults(t *testing.T) { { name: "set non default parallelism", config: &v1beta3.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(8), + Parallelism: pointer.Int32(8), }, expected: &v1beta3.KubeSchedulerConfiguration{ - Parallelism: pointer.Int32Ptr(8), + Parallelism: pointer.Int32(8), DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{ EnableProfiling: &enable, EnableContentionProfiling: &enable, }, LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ - LeaderElect: pointer.BoolPtr(true), + LeaderElect: pointer.Bool(true), LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, RetryPeriod: metav1.Duration{Duration: 2 * time.Second}, @@ -425,14 +425,14 @@ func TestSchedulerDefaults(t *testing.T) { Burst: 100, ContentType: "application/vnd.kubernetes.protobuf", }, - PercentageOfNodesToScore: pointer.Int32Ptr(0), - PodInitialBackoffSeconds: pointer.Int64Ptr(1), - PodMaxBackoffSeconds: pointer.Int64Ptr(10), + PercentageOfNodesToScore: pointer.Int32(0), + PodInitialBackoffSeconds: pointer.Int64(1), + PodMaxBackoffSeconds: pointer.Int64(10), Profiles: []v1beta3.KubeSchedulerProfile{ { Plugins: getDefaultPlugins(), PluginConfig: pluginConfigs, - SchedulerName: pointer.StringPtr("default-scheduler"), + SchedulerName: pointer.String("default-scheduler"), }, }, }, @@ -459,43 +459,43 @@ func TestPluginArgsDefaults(t *testing.T) { name: "DefaultPreemptionArgs empty", in: &v1beta3.DefaultPreemptionArgs{}, want: &v1beta3.DefaultPreemptionArgs{ - MinCandidateNodesPercentage: pointer.Int32Ptr(10), - MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + MinCandidateNodesPercentage: pointer.Int32(10), + MinCandidateNodesAbsolute: pointer.Int32(100), }, }, { name: "DefaultPreemptionArgs with value", in: &v1beta3.DefaultPreemptionArgs{ - MinCandidateNodesPercentage: pointer.Int32Ptr(50), + MinCandidateNodesPercentage: pointer.Int32(50), }, want: &v1beta3.DefaultPreemptionArgs{ - MinCandidateNodesPercentage: pointer.Int32Ptr(50), - MinCandidateNodesAbsolute: pointer.Int32Ptr(100), + MinCandidateNodesPercentage: pointer.Int32(50), + MinCandidateNodesAbsolute: pointer.Int32(100), }, }, { name: "InterPodAffinityArgs empty", in: &v1beta3.InterPodAffinityArgs{}, want: &v1beta3.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(1), + HardPodAffinityWeight: pointer.Int32(1), }, }, { name: "InterPodAffinityArgs explicit 0", in: &v1beta3.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(0), + HardPodAffinityWeight: pointer.Int32(0), }, want: &v1beta3.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(0), + HardPodAffinityWeight: pointer.Int32(0), }, }, { name: "InterPodAffinityArgs with value", in: &v1beta3.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(5), + HardPodAffinityWeight: pointer.Int32(5), }, want: &v1beta3.InterPodAffinityArgs{ - HardPodAffinityWeight: pointer.Int32Ptr(5), + HardPodAffinityWeight: pointer.Int32(5), }, }, { @@ -612,7 +612,7 @@ func TestPluginArgsDefaults(t *testing.T) { }, in: &v1beta3.VolumeBindingArgs{}, want: &v1beta3.VolumeBindingArgs{ - BindTimeoutSeconds: pointer.Int64Ptr(600), + BindTimeoutSeconds: pointer.Int64(600), }, }, { @@ -622,7 +622,7 @@ func TestPluginArgsDefaults(t *testing.T) { }, in: &v1beta3.VolumeBindingArgs{}, want: &v1beta3.VolumeBindingArgs{ - BindTimeoutSeconds: pointer.Int64Ptr(600), + BindTimeoutSeconds: pointer.Int64(600), Shape: []v1beta3.UtilizationShapePoint{ {Utilization: 0, Score: 0}, {Utilization: 100, Score: 10}, diff --git a/pkg/scheduler/framework/plugins/nodevolumelimits/csi_test.go b/pkg/scheduler/framework/plugins/nodevolumelimits/csi_test.go index 420493394a5..f26c9b8cf00 100644 --- a/pkg/scheduler/framework/plugins/nodevolumelimits/csi_test.go +++ b/pkg/scheduler/framework/plugins/nodevolumelimits/csi_test.go @@ -35,7 +35,7 @@ import ( fakeframework "k8s.io/kubernetes/pkg/scheduler/framework/fake" st "k8s.io/kubernetes/pkg/scheduler/testing" volumeutil "k8s.io/kubernetes/pkg/volume/util" - utilpointer "k8s.io/utils/pointer" + "k8s.io/utils/pointer" ) const ( @@ -638,7 +638,7 @@ func getNodeWithPodAndVolumeLimits(limitSource string, pods []*v1.Pod, limit int } if addLimits { driver.Allocatable = &storagev1.VolumeNodeResources{ - Count: utilpointer.Int32Ptr(int32(limit)), + Count: pointer.Int32(int32(limit)), } } csiNode.Spec.Drivers = append(csiNode.Spec.Drivers, driver) diff --git a/pkg/scheduler/framework/plugins/nodevolumelimits/non_csi_test.go b/pkg/scheduler/framework/plugins/nodevolumelimits/non_csi_test.go index 922abd071db..e74787edb98 100644 --- a/pkg/scheduler/framework/plugins/nodevolumelimits/non_csi_test.go +++ b/pkg/scheduler/framework/plugins/nodevolumelimits/non_csi_test.go @@ -31,7 +31,7 @@ import ( fakeframework "k8s.io/kubernetes/pkg/scheduler/framework/fake" "k8s.io/kubernetes/pkg/scheduler/framework/plugins/feature" st "k8s.io/kubernetes/pkg/scheduler/testing" - utilpointer "k8s.io/utils/pointer" + "k8s.io/utils/pointer" ) var ( @@ -792,14 +792,14 @@ func getFakePVCLister(filterName string) fakeframework.PersistentVolumeClaimList ObjectMeta: metav1.ObjectMeta{Name: "unboundPVCWithDefaultSCPod"}, Spec: v1.PersistentVolumeClaimSpec{ VolumeName: "", - StorageClassName: utilpointer.StringPtr("standard-sc"), + StorageClassName: pointer.String("standard-sc"), }, }, { ObjectMeta: metav1.ObjectMeta{Name: "unboundPVCWithInvalidSCPod"}, Spec: v1.PersistentVolumeClaimSpec{ VolumeName: "", - StorageClassName: utilpointer.StringPtr("invalid-sc"), + StorageClassName: pointer.String("invalid-sc"), }, }, } diff --git a/pkg/scheduler/framework/plugins/podtopologyspread/scoring_test.go b/pkg/scheduler/framework/plugins/podtopologyspread/scoring_test.go index 6a602ea32fc..712cc14baa9 100644 --- a/pkg/scheduler/framework/plugins/podtopologyspread/scoring_test.go +++ b/pkg/scheduler/framework/plugins/podtopologyspread/scoring_test.go @@ -86,8 +86,8 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: "zone", value: "zone1"}: pointer.Int64Ptr(0), - {key: "zone", value: "zone2"}: pointer.Int64Ptr(0), + {key: "zone", value: "zone1"}: pointer.Int64(0), + {key: "zone", value: "zone2"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2), topologyNormalizingWeight(3)}, }, @@ -127,7 +127,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString("node-x"), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: "zone", value: "zone1"}: pointer.Int64Ptr(0), + {key: "zone", value: "zone1"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(1), topologyNormalizingWeight(2)}, }, @@ -169,8 +169,8 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: v1.LabelTopologyZone, value: "mars"}: pointer.Int64Ptr(0), - {key: v1.LabelTopologyZone, value: ""}: pointer.Int64Ptr(0), + {key: v1.LabelTopologyZone, value: "mars"}: pointer.Int64(0), + {key: v1.LabelTopologyZone, value: ""}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(4), topologyNormalizingWeight(2)}, }, @@ -220,7 +220,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: "planet", value: "mars"}: pointer.Int64Ptr(0), + {key: "planet", value: "mars"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(1), topologyNormalizingWeight(1)}, }, @@ -284,7 +284,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {"planet", "mars"}: pointer.Int64Ptr(0), + {"planet", "mars"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(1)}, }, @@ -316,8 +316,8 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: "zone", value: "zone1"}: pointer.Int64Ptr(0), - {key: "zone", value: "zone2"}: pointer.Int64Ptr(0), + {key: "zone", value: "zone1"}: pointer.Int64(0), + {key: "zone", value: "zone2"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)}, }, @@ -350,8 +350,8 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: "zone", value: "zone1"}: pointer.Int64Ptr(0), - {key: "zone", value: "zone2"}: pointer.Int64Ptr(0), + {key: "zone", value: "zone1"}: pointer.Int64(0), + {key: "zone", value: "zone2"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)}, }, @@ -384,8 +384,8 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: "zone", value: "zone1"}: pointer.Int64Ptr(0), - {key: "zone", value: "zone2"}: pointer.Int64Ptr(0), + {key: "zone", value: "zone1"}: pointer.Int64(0), + {key: "zone", value: "zone2"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)}, }, @@ -418,8 +418,8 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: "zone", value: "zone1"}: pointer.Int64Ptr(0), - {key: "zone", value: "zone2"}: pointer.Int64Ptr(0), + {key: "zone", value: "zone1"}: pointer.Int64(0), + {key: "zone", value: "zone2"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)}, }, @@ -451,8 +451,8 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: "zone", value: "zone1"}: pointer.Int64Ptr(0), - {key: "zone", value: "zone2"}: pointer.Int64Ptr(0), + {key: "zone", value: "zone1"}: pointer.Int64(0), + {key: "zone", value: "zone2"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)}, }, @@ -484,8 +484,8 @@ func TestPreScoreStateEmptyNodes(t *testing.T) { }, IgnoredNodes: sets.NewString(), TopologyPairToPodCounts: map[topologyPair]*int64{ - {key: "zone", value: "zone1"}: pointer.Int64Ptr(0), - {key: "zone", value: "zone2"}: pointer.Int64Ptr(0), + {key: "zone", value: "zone1"}: pointer.Int64(0), + {key: "zone", value: "zone2"}: pointer.Int64(0), }, TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)}, }, diff --git a/pkg/scheduler/framework/plugins/selectorspread/selector_spread_test.go b/pkg/scheduler/framework/plugins/selectorspread/selector_spread_test.go index 0e2ad527e6c..69564fb2be7 100644 --- a/pkg/scheduler/framework/plugins/selectorspread/selector_spread_test.go +++ b/pkg/scheduler/framework/plugins/selectorspread/selector_spread_test.go @@ -50,7 +50,7 @@ func controllerRef(name string, gvk schema.GroupVersionKind) []metav1.OwnerRefer APIVersion: gvk.GroupVersion().String(), Kind: gvk.Kind, Name: name, - Controller: pointer.BoolPtr(true), + Controller: pointer.Bool(true), }, } } diff --git a/pkg/scheduler/framework/plugins/volumebinding/test_utils.go b/pkg/scheduler/framework/plugins/volumebinding/test_utils.go index 44841094481..d58e3667999 100644 --- a/pkg/scheduler/framework/plugins/volumebinding/test_utils.go +++ b/pkg/scheduler/framework/plugins/volumebinding/test_utils.go @@ -115,7 +115,7 @@ func makePVC(name string, storageClassName string) pvcBuilder { Namespace: v1.NamespaceDefault, }, Spec: v1.PersistentVolumeClaimSpec{ - StorageClassName: pointer.StringPtr(storageClassName), + StorageClassName: pointer.String(storageClassName), }, }} } diff --git a/pkg/scheduler/schedule_one_test.go b/pkg/scheduler/schedule_one_test.go index 7807430e0a2..a782af5f7c5 100644 --- a/pkg/scheduler/schedule_one_test.go +++ b/pkg/scheduler/schedule_one_test.go @@ -1922,7 +1922,7 @@ func TestSchedulerSchedulePod(t *testing.T) { nodes: []string{"node1", "node2", "node3"}, pod: st.MakePod().Name("test-prefilter").UID("test-prefilter").Obj(), wantNodes: sets.NewString("node2"), - wantEvaluatedNodes: pointer.Int32Ptr(1), + wantEvaluatedNodes: pointer.Int32(1), }, { name: "test prefilter plugin returning non-intersecting nodes", diff --git a/pkg/scheduler/testing/wrappers.go b/pkg/scheduler/testing/wrappers.go index a77cdc40ad6..33f6e15e1be 100644 --- a/pkg/scheduler/testing/wrappers.go +++ b/pkg/scheduler/testing/wrappers.go @@ -230,7 +230,7 @@ func (p *PodWrapper) OwnerReference(name string, gvk schema.GroupVersionKind) *P APIVersion: gvk.GroupVersion().String(), Kind: gvk.Kind, Name: name, - Controller: pointer.BoolPtr(true), + Controller: pointer.Bool(true), }, } return p