Skip to content

Commit

Permalink
Merge pull request #1464 from eminaktas/update-pointer-to-ptr
Browse files Browse the repository at this point in the history
refactor: replace k8s.io/utils/pointer with k8s.io/utils/ptr
  • Loading branch information
k8s-ci-robot authored Jul 11, 2024
2 parents a2a45db + f8e128d commit eb6c325
Show file tree
Hide file tree
Showing 23 changed files with 309 additions and 120 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
k8s.io/component-base v0.30.0
k8s.io/component-helpers v0.30.0
k8s.io/klog/v2 v2.120.1
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
sigs.k8s.io/mdtoc v1.1.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ k8s.io/kms v0.30.0 h1:ZlnD/ei5lpvUlPw6eLfVvH7d8i9qZ6HwUQgydNVks8g=
k8s.io/kms v0.30.0/go.mod h1:GrMurD0qk3G4yNgGcsCEmepqf9KyyIrTXYR2lyUOJC4=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98=
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY=
k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 h1:/U5vjBbQn3RChhv7P11uhYvCSm5G2GaIi5AIGBS6r4c=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0/go.mod h1:z7+wmGM2dfIiLRfrC6jb5kV2Mq/sK1ZP303cxzkV5Y4=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v1alpha1/strategymigration.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

v1 "k8s.io/api/core/v1"
"k8s.io/klog/v2"
utilpointer "k8s.io/utils/pointer"
utilptr "k8s.io/utils/ptr"
"sigs.k8s.io/descheduler/pkg/api"
"sigs.k8s.io/descheduler/pkg/framework/plugins/nodeutilization"
"sigs.k8s.io/descheduler/pkg/framework/plugins/podlifetime"
Expand Down Expand Up @@ -180,7 +180,7 @@ var StrategyParamsToPluginArgs = map[string]func(params *StrategyParameters) (*a
Namespaces: v1alpha1NamespacesToInternal(params.Namespaces),
LabelSelector: params.LabelSelector,
Constraints: constraints,
TopologyBalanceNodeFit: utilpointer.Bool(true),
TopologyBalanceNodeFit: utilptr.To(true),
}
if err := removepodsviolatingtopologyspreadconstraint.ValidateRemovePodsViolatingTopologySpreadConstraintArgs(args); err != nil {
klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", removepodsviolatingtopologyspreadconstraint.PluginName)
Expand Down
38 changes: 19 additions & 19 deletions pkg/api/v1alpha1/strategymigration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1"
utilpointer "k8s.io/utils/pointer"
utilptr "k8s.io/utils/ptr"
"sigs.k8s.io/descheduler/pkg/api"
"sigs.k8s.io/descheduler/pkg/framework/plugins/nodeutilization"
"sigs.k8s.io/descheduler/pkg/framework/plugins/podlifetime"
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestStrategyParamsToPluginArgsRemovePodsViolatingNodeTaints(t *testing.T) {
"dedicated=special-user",
"reserved",
},
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand Down Expand Up @@ -116,12 +116,12 @@ func TestStrategyParamsToPluginArgsRemoveFailedPods(t *testing.T) {
description: "wire in all valid parameters",
params: &StrategyParameters{
FailedPods: &FailedPods{
MinPodLifetimeSeconds: utilpointer.Uint(3600),
MinPodLifetimeSeconds: utilptr.To[uint](3600),
ExcludeOwnerKinds: []string{"Job"},
Reasons: []string{"NodeAffinity"},
IncludingInitContainers: true,
},
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand All @@ -131,7 +131,7 @@ func TestStrategyParamsToPluginArgsRemoveFailedPods(t *testing.T) {
Name: removefailedpods.PluginName,
Args: &removefailedpods.RemoveFailedPodsArgs{
ExcludeOwnerKinds: []string{"Job"},
MinPodLifetimeSeconds: utilpointer.Uint(3600),
MinPodLifetimeSeconds: utilptr.To[uint](3600),
Reasons: []string{"NodeAffinity"},
IncludingInitContainers: true,
Namespaces: &api.Namespaces{
Expand Down Expand Up @@ -189,7 +189,7 @@ func TestStrategyParamsToPluginArgsRemovePodsViolatingNodeAffinity(t *testing.T)
description: "wire in all valid parameters",
params: &StrategyParameters{
NodeAffinityType: []string{"requiredDuringSchedulingIgnoredDuringExecution"},
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestStrategyParamsToPluginArgsRemovePodsViolatingInterPodAntiAffinity(t *te
{
description: "wire in all valid parameters",
params: &StrategyParameters{
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand Down Expand Up @@ -327,7 +327,7 @@ func TestStrategyParamsToPluginArgsRemovePodsHavingTooManyRestarts(t *testing.T)
PodRestartThreshold: 100,
IncludingInitContainers: true,
},
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand Down Expand Up @@ -403,13 +403,13 @@ func TestStrategyParamsToPluginArgsPodLifeTime(t *testing.T) {
description: "wire in all valid parameters",
params: &StrategyParameters{
PodLifeTime: &PodLifeTime{
MaxPodLifeTimeSeconds: utilpointer.Uint(86400),
MaxPodLifeTimeSeconds: utilptr.To[uint](86400),
States: []string{
"Pending",
"PodInitializing",
},
},
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand All @@ -418,7 +418,7 @@ func TestStrategyParamsToPluginArgsPodLifeTime(t *testing.T) {
result: &api.PluginConfig{
Name: podlifetime.PluginName,
Args: &podlifetime.PodLifeTimeArgs{
MaxPodLifeTimeSeconds: utilpointer.Uint(86400),
MaxPodLifeTimeSeconds: utilptr.To[uint](86400),
States: []string{
"Pending",
"PodInitializing",
Expand All @@ -433,7 +433,7 @@ func TestStrategyParamsToPluginArgsPodLifeTime(t *testing.T) {
description: "invalid params namespaces",
params: &StrategyParameters{
PodLifeTime: &PodLifeTime{
MaxPodLifeTimeSeconds: utilpointer.Uint(86400),
MaxPodLifeTimeSeconds: utilptr.To[uint](86400),
},
Namespaces: &Namespaces{
Exclude: []string{"test1"},
Expand Down Expand Up @@ -491,7 +491,7 @@ func TestStrategyParamsToPluginArgsRemoveDuplicates(t *testing.T) {
RemoveDuplicates: &RemoveDuplicates{
ExcludeOwnerKinds: []string{"ReplicaSet"},
},
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand All @@ -511,7 +511,7 @@ func TestStrategyParamsToPluginArgsRemoveDuplicates(t *testing.T) {
description: "invalid params namespaces",
params: &StrategyParameters{
PodLifeTime: &PodLifeTime{
MaxPodLifeTimeSeconds: utilpointer.Uint(86400),
MaxPodLifeTimeSeconds: utilptr.To[uint](86400),
},
Namespaces: &Namespaces{
Exclude: []string{"test1"},
Expand Down Expand Up @@ -559,7 +559,7 @@ func TestStrategyParamsToPluginArgsRemovePodsViolatingTopologySpreadConstraint(t
description: "wire in all valid parameters",
params: &StrategyParameters{
IncludeSoftConstraints: true,
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand All @@ -569,7 +569,7 @@ func TestStrategyParamsToPluginArgsRemovePodsViolatingTopologySpreadConstraint(t
Name: removepodsviolatingtopologyspreadconstraint.PluginName,
Args: &removepodsviolatingtopologyspreadconstraint.RemovePodsViolatingTopologySpreadConstraintArgs{
Constraints: []v1.UnsatisfiableConstraintAction{v1.DoNotSchedule, v1.ScheduleAnyway},
TopologyBalanceNodeFit: utilpointer.Bool(true),
TopologyBalanceNodeFit: utilptr.To(true),
Namespaces: &api.Namespaces{
Exclude: []string{"test1"},
},
Expand All @@ -586,7 +586,7 @@ func TestStrategyParamsToPluginArgsRemovePodsViolatingTopologySpreadConstraint(t
Name: removepodsviolatingtopologyspreadconstraint.PluginName,
Args: &removepodsviolatingtopologyspreadconstraint.RemovePodsViolatingTopologySpreadConstraintArgs{
Constraints: []v1.UnsatisfiableConstraintAction{v1.DoNotSchedule},
TopologyBalanceNodeFit: utilpointer.Bool(true),
TopologyBalanceNodeFit: utilptr.To(true),
},
},
},
Expand Down Expand Up @@ -646,7 +646,7 @@ func TestStrategyParamsToPluginArgsHighNodeUtilization(t *testing.T) {
"pods": Percentage(20),
},
},
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand Down Expand Up @@ -759,7 +759,7 @@ func TestStrategyParamsToPluginArgsLowNodeUtilization(t *testing.T) {
},
UseDeviationThresholds: true,
},
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
Namespaces: &Namespaces{
Exclude: []string{"test1"},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/descheduler/evictions/evictions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"k8s.io/client-go/kubernetes/fake"
core "k8s.io/client-go/testing"
"k8s.io/client-go/tools/events"
utilpointer "k8s.io/utils/pointer"
utilptr "k8s.io/utils/ptr"
podutil "sigs.k8s.io/descheduler/pkg/descheduler/pod"
"sigs.k8s.io/descheduler/pkg/utils"
"sigs.k8s.io/descheduler/test"
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestNewPodEvictor(t *testing.T) {
podEvictor := NewPodEvictor(
fakeClient,
eventRecorder,
NewOptions().WithMaxPodsToEvictPerNode(utilpointer.Uint(1)),
NewOptions().WithMaxPodsToEvictPerNode(utilptr.To[uint](1)),
)

stubNode := &v1.Node{ObjectMeta: metav1.ObjectMeta{Name: "node"}}
Expand Down
40 changes: 20 additions & 20 deletions pkg/descheduler/policyconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/conversion"
fakeclientset "k8s.io/client-go/kubernetes/fake"
utilpointer "k8s.io/utils/pointer"
utilptr "k8s.io/utils/ptr"
"sigs.k8s.io/descheduler/pkg/api"
"sigs.k8s.io/descheduler/pkg/api/v1alpha1"
"sigs.k8s.io/descheduler/pkg/framework/pluginregistry"
Expand Down Expand Up @@ -154,11 +154,11 @@ func TestV1alpha1ToV1alpha2(t *testing.T) {
{
description: "convert global policy fields to defaultevictor",
policy: &v1alpha1.DeschedulerPolicy{
EvictFailedBarePods: utilpointer.Bool(true),
EvictLocalStoragePods: utilpointer.Bool(true),
EvictSystemCriticalPods: utilpointer.Bool(true),
EvictDaemonSetPods: utilpointer.Bool(true),
IgnorePVCPods: utilpointer.Bool(true),
EvictFailedBarePods: utilptr.To(true),
EvictLocalStoragePods: utilptr.To(true),
EvictSystemCriticalPods: utilptr.To(true),
EvictDaemonSetPods: utilptr.To(true),
IgnorePVCPods: utilptr.To(true),
Strategies: v1alpha1.StrategyList{
removeduplicates.PluginName: v1alpha1.DeschedulerStrategy{
Enabled: true,
Expand Down Expand Up @@ -484,7 +484,7 @@ func TestV1alpha1ToV1alpha2(t *testing.T) {
Name: removepodsviolatingtopologyspreadconstraint.PluginName,
Args: &removepodsviolatingtopologyspreadconstraint.RemovePodsViolatingTopologySpreadConstraintArgs{
Constraints: []v1.UnsatisfiableConstraintAction{v1.DoNotSchedule},
TopologyBalanceNodeFit: utilpointer.Bool(true),
TopologyBalanceNodeFit: utilptr.To(true),
},
},
},
Expand Down Expand Up @@ -550,7 +550,7 @@ func TestV1alpha1ToV1alpha2(t *testing.T) {
Enabled: true,
Params: &v1alpha1.StrategyParameters{
FailedPods: &v1alpha1.FailedPods{
MinPodLifetimeSeconds: utilpointer.Uint(3600),
MinPodLifetimeSeconds: utilptr.To[uint](3600),
ExcludeOwnerKinds: []string{"Job"},
Reasons: []string{"NodeAffinity"},
IncludingInitContainers: true,
Expand Down Expand Up @@ -684,7 +684,7 @@ func TestV1alpha1ToV1alpha2(t *testing.T) {
Name: removefailedpods.PluginName,
Args: &removefailedpods.RemoveFailedPodsArgs{
ExcludeOwnerKinds: []string{"Job"},
MinPodLifetimeSeconds: utilpointer.Uint(3600),
MinPodLifetimeSeconds: utilptr.To[uint](3600),
Reasons: []string{"NodeAffinity"},
IncludingInitContainers: true,
},
Expand Down Expand Up @@ -801,7 +801,7 @@ func TestV1alpha1ToV1alpha2(t *testing.T) {
Name: removepodsviolatingtopologyspreadconstraint.PluginName,
Args: &removepodsviolatingtopologyspreadconstraint.RemovePodsViolatingTopologySpreadConstraintArgs{
Constraints: []v1.UnsatisfiableConstraintAction{v1.DoNotSchedule, v1.ScheduleAnyway},
TopologyBalanceNodeFit: utilpointer.Bool(true),
TopologyBalanceNodeFit: utilptr.To(true),
},
},
},
Expand Down Expand Up @@ -837,7 +837,7 @@ func TestV1alpha1ToV1alpha2(t *testing.T) {
nodeutilization.LowNodeUtilizationPluginName: v1alpha1.DeschedulerStrategy{
Enabled: true,
Params: &v1alpha1.StrategyParameters{
ThresholdPriority: utilpointer.Int32(100),
ThresholdPriority: utilptr.To[int32](100),
ThresholdPriorityClassName: "name",
NodeResourceUtilizationThresholds: &v1alpha1.NodeResourceUtilizationThresholds{
Thresholds: v1alpha1.ResourceThresholds{
Expand Down Expand Up @@ -888,7 +888,7 @@ func TestDecodeVersionedPolicy(t *testing.T) {
Name: defaultevictor.PluginName,
Args: &defaultevictor.DefaultEvictorArgs{
PriorityThreshold: &api.PriorityThreshold{
Value: utilpointer.Int32(utils.SystemCriticalPriority),
Value: utilptr.To[int32](utils.SystemCriticalPriority),
},
},
}
Expand Down Expand Up @@ -925,7 +925,7 @@ strategies:
Namespaces: &api.Namespaces{
Include: []string{"testleaderelection-a"},
},
MaxPodLifeTimeSeconds: utilpointer.Uint(5),
MaxPodLifeTimeSeconds: utilptr.To[uint](5),
},
},
},
Expand Down Expand Up @@ -969,7 +969,7 @@ strategies:
Name: "DefaultEvictor",
Args: &defaultevictor.DefaultEvictorArgs{
PriorityThreshold: &api.PriorityThreshold{
Value: utilpointer.Int32(0),
Value: utilptr.To[int32](0),
},
},
},
Expand All @@ -979,7 +979,7 @@ strategies:
Namespaces: &api.Namespaces{
Include: []string{"testleaderelection-a"},
},
MaxPodLifeTimeSeconds: utilpointer.Uint(5),
MaxPodLifeTimeSeconds: utilptr.To[uint](5),
},
},
},
Expand Down Expand Up @@ -1052,7 +1052,7 @@ profiles:
EvictFailedBarePods: true,
EvictLocalStoragePods: true,
EvictDaemonSetPods: true,
PriorityThreshold: &api.PriorityThreshold{Value: utilpointer.Int32(2000000000)},
PriorityThreshold: &api.PriorityThreshold{Value: utilptr.To[int32](2000000000)},
NodeFit: true,
},
},
Expand Down Expand Up @@ -1209,14 +1209,14 @@ profiles:
EvictFailedBarePods: true,
EvictLocalStoragePods: true,
EvictDaemonSetPods: true,
PriorityThreshold: &api.PriorityThreshold{Value: utilpointer.Int32(2000000000)},
PriorityThreshold: &api.PriorityThreshold{Value: utilptr.To[int32](2000000000)},
NodeFit: true,
},
},
{
Name: removefailedpods.PluginName,
Args: &removefailedpods.RemoveFailedPodsArgs{
MinPodLifetimeSeconds: utilpointer.Uint(3600),
MinPodLifetimeSeconds: utilptr.To[uint](3600),
},
},
},
Expand Down Expand Up @@ -1267,14 +1267,14 @@ profiles:
EvictFailedBarePods: true,
EvictLocalStoragePods: true,
EvictDaemonSetPods: true,
PriorityThreshold: &api.PriorityThreshold{Value: utilpointer.Int32(2000000000)},
PriorityThreshold: &api.PriorityThreshold{Value: utilptr.To[int32](2000000000)},
NodeFit: true,
},
},
{
Name: removefailedpods.PluginName,
Args: &removefailedpods.RemoveFailedPodsArgs{
MinPodLifetimeSeconds: utilpointer.Uint(3600),
MinPodLifetimeSeconds: utilptr.To[uint](3600),
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/framework/plugins/defaultevictor/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/utils/pointer"
utilptr "k8s.io/utils/ptr"
"sigs.k8s.io/descheduler/pkg/api"
)

Expand Down Expand Up @@ -55,7 +55,7 @@ func TestSetDefaults_DefaultEvictorArgs(t *testing.T) {
EvictFailedBarePods: true,
LabelSelector: nil,
PriorityThreshold: &api.PriorityThreshold{
Value: pointer.Int32(800),
Value: utilptr.To[int32](800),
},
NodeFit: true,
},
Expand All @@ -68,7 +68,7 @@ func TestSetDefaults_DefaultEvictorArgs(t *testing.T) {
EvictFailedBarePods: true,
LabelSelector: nil,
PriorityThreshold: &api.PriorityThreshold{
Value: pointer.Int32(800),
Value: utilptr.To[int32](800),
},
NodeFit: true,
},
Expand Down
Loading

0 comments on commit eb6c325

Please sign in to comment.