From c127763a4529d7d07961102856afe0ba8781f8ee Mon Sep 17 00:00:00 2001 From: mikelo Date: Fri, 24 Jun 2022 19:13:03 +0200 Subject: [PATCH] switched policy for PodDisruptionBudget from v1beta1 to v1 in time for 1.25 --- .../core/scaledown/actuation/drain.go | 5 +++-- .../core/scaledown/actuation/drain_test.go | 14 +++++++------- cluster-autoscaler/core/scaledown/legacy/legacy.go | 2 +- .../core/scaledown/legacy/wrapper.go | 2 +- cluster-autoscaler/core/scaledown/scaledown.go | 2 +- cluster-autoscaler/core/static_autoscaler_test.go | 2 +- cluster-autoscaler/simulator/cluster.go | 2 +- cluster-autoscaler/simulator/cluster_test.go | 2 +- cluster-autoscaler/simulator/drain.go | 2 +- cluster-autoscaler/simulator/drain_test.go | 2 +- cluster-autoscaler/utils/drain/drain.go | 2 +- cluster-autoscaler/utils/drain/drain_test.go | 2 +- cluster-autoscaler/utils/kubernetes/listers.go | 6 +++--- 13 files changed, 23 insertions(+), 22 deletions(-) diff --git a/cluster-autoscaler/core/scaledown/actuation/drain.go b/cluster-autoscaler/core/scaledown/actuation/drain.go index cd3d9942b00b..437bb739b331 100644 --- a/cluster-autoscaler/core/scaledown/actuation/drain.go +++ b/cluster-autoscaler/core/scaledown/actuation/drain.go @@ -23,7 +23,8 @@ import ( "time" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" + policyv1beta1 "k8s.io/api/policy/v1beta1" kube_errors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog/v2" @@ -223,7 +224,7 @@ func evictPod(ctx *acontext.AutoscalingContext, podToEvict *apiv1.Pod, isDaemonS var lastError error for first := true; first || time.Now().Before(retryUntil); time.Sleep(waitBetweenRetries) { first = false - eviction := &policyv1.Eviction{ + eviction := &policyv1beta1.Eviction{ ObjectMeta: metav1.ObjectMeta{ Namespace: podToEvict.Namespace, Name: podToEvict.Name, diff --git a/cluster-autoscaler/core/scaledown/actuation/drain_test.go b/cluster-autoscaler/core/scaledown/actuation/drain_test.go index fa1fd4edb2a8..7c1b024592c8 100644 --- a/cluster-autoscaler/core/scaledown/actuation/drain_test.go +++ b/cluster-autoscaler/core/scaledown/actuation/drain_test.go @@ -27,7 +27,7 @@ import ( "github.com/stretchr/testify/assert" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1beta1 "k8s.io/api/policy/v1beta1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -151,7 +151,7 @@ func TestDaemonSetEvictionForEmptyNodes(t *testing.T) { if createAction == nil { return false, nil, nil } - eviction := createAction.GetObject().(*policyv1.Eviction) + eviction := createAction.GetObject().(*policyv1beta1.Eviction) if eviction == nil { return false, nil, nil } @@ -224,7 +224,7 @@ func TestDrainNodeWithPods(t *testing.T) { if createAction == nil { return false, nil, nil } - eviction := createAction.GetObject().(*policyv1.Eviction) + eviction := createAction.GetObject().(*policyv1beta1.Eviction) if eviction == nil { return false, nil, nil } @@ -279,7 +279,7 @@ func TestDrainNodeWithPodsWithRescheduled(t *testing.T) { if createAction == nil { return false, nil, nil } - eviction := createAction.GetObject().(*policyv1.Eviction) + eviction := createAction.GetObject().(*policyv1beta1.Eviction) if eviction == nil { return false, nil, nil } @@ -329,7 +329,7 @@ func TestDrainNodeWithPodsWithRetries(t *testing.T) { if createAction == nil { return false, nil, nil } - eviction := createAction.GetObject().(*policyv1.Eviction) + eviction := createAction.GetObject().(*policyv1beta1.Eviction) if eviction == nil { return false, nil, nil } @@ -387,7 +387,7 @@ func TestDrainNodeWithPodsDaemonSetEvictionFailure(t *testing.T) { if createAction == nil { return false, nil, nil } - eviction := createAction.GetObject().(*policyv1.Eviction) + eviction := createAction.GetObject().(*policyv1beta1.Eviction) if eviction == nil { return false, nil, nil } @@ -438,7 +438,7 @@ func TestDrainNodeWithPodsEvictionFailure(t *testing.T) { if createAction == nil { return false, nil, nil } - eviction := createAction.GetObject().(*policyv1.Eviction) + eviction := createAction.GetObject().(*policyv1beta1.Eviction) if eviction == nil { return false, nil, nil } diff --git a/cluster-autoscaler/core/scaledown/legacy/legacy.go b/cluster-autoscaler/core/scaledown/legacy/legacy.go index 10f4631dd04b..330dac3fd7c9 100644 --- a/cluster-autoscaler/core/scaledown/legacy/legacy.go +++ b/cluster-autoscaler/core/scaledown/legacy/legacy.go @@ -40,7 +40,7 @@ import ( kube_util "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" klog "k8s.io/klog/v2" diff --git a/cluster-autoscaler/core/scaledown/legacy/wrapper.go b/cluster-autoscaler/core/scaledown/legacy/wrapper.go index 8f467841fb8d..d48bdd22e811 100644 --- a/cluster-autoscaler/core/scaledown/legacy/wrapper.go +++ b/cluster-autoscaler/core/scaledown/legacy/wrapper.go @@ -27,7 +27,7 @@ import ( "k8s.io/autoscaler/cluster-autoscaler/utils/errors" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" ) // ScaleDownWrapper wraps legacy scaledown logic to satisfy scaledown.Planner & diff --git a/cluster-autoscaler/core/scaledown/scaledown.go b/cluster-autoscaler/core/scaledown/scaledown.go index 6fdf0d649d42..218a886ca958 100644 --- a/cluster-autoscaler/core/scaledown/scaledown.go +++ b/cluster-autoscaler/core/scaledown/scaledown.go @@ -25,7 +25,7 @@ import ( "k8s.io/autoscaler/cluster-autoscaler/utils/errors" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" ) // Planner is responsible for selecting nodes that should be removed. diff --git a/cluster-autoscaler/core/static_autoscaler_test.go b/cluster-autoscaler/core/static_autoscaler_test.go index cfc8e749660d..ad0011e1063c 100644 --- a/cluster-autoscaler/core/static_autoscaler_test.go +++ b/cluster-autoscaler/core/static_autoscaler_test.go @@ -45,7 +45,7 @@ import ( appsv1 "k8s.io/api/apps/v1" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/kubernetes/fake" v1appslister "k8s.io/client-go/listers/apps/v1" diff --git a/cluster-autoscaler/simulator/cluster.go b/cluster-autoscaler/simulator/cluster.go index d16fc1711a38..278a4c39d23b 100644 --- a/cluster-autoscaler/simulator/cluster.go +++ b/cluster-autoscaler/simulator/cluster.go @@ -27,7 +27,7 @@ import ( "k8s.io/autoscaler/cluster-autoscaler/utils/tpu" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework" klog "k8s.io/klog/v2" diff --git a/cluster-autoscaler/simulator/cluster_test.go b/cluster-autoscaler/simulator/cluster_test.go index 718f18cbff56..f7e516073005 100644 --- a/cluster-autoscaler/simulator/cluster_test.go +++ b/cluster-autoscaler/simulator/cluster_test.go @@ -23,7 +23,7 @@ import ( appsv1 "k8s.io/api/apps/v1" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/autoscaler/cluster-autoscaler/utils/drain" kube_util "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes" diff --git a/cluster-autoscaler/simulator/drain.go b/cluster-autoscaler/simulator/drain.go index bdaf779d5fe8..cc572838586e 100644 --- a/cluster-autoscaler/simulator/drain.go +++ b/cluster-autoscaler/simulator/drain.go @@ -21,7 +21,7 @@ import ( "time" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/autoscaler/cluster-autoscaler/utils/drain" diff --git a/cluster-autoscaler/simulator/drain_test.go b/cluster-autoscaler/simulator/drain_test.go index 3fa44812a2f5..347b978f6c2f 100644 --- a/cluster-autoscaler/simulator/drain_test.go +++ b/cluster-autoscaler/simulator/drain_test.go @@ -21,7 +21,7 @@ import ( "time" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/autoscaler/cluster-autoscaler/utils/drain" diff --git a/cluster-autoscaler/utils/drain/drain.go b/cluster-autoscaler/utils/drain/drain.go index a5ae4c812af5..e1be05665352 100644 --- a/cluster-autoscaler/utils/drain/drain.go +++ b/cluster-autoscaler/utils/drain/drain.go @@ -21,7 +21,7 @@ import ( "time" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" diff --git a/cluster-autoscaler/utils/drain/drain_test.go b/cluster-autoscaler/utils/drain/drain_test.go index 5a683a1888e6..a02f198f0be1 100644 --- a/cluster-autoscaler/utils/drain/drain_test.go +++ b/cluster-autoscaler/utils/drain/drain_test.go @@ -23,7 +23,7 @@ import ( appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kube_util "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes" . "k8s.io/autoscaler/cluster-autoscaler/utils/test" diff --git a/cluster-autoscaler/utils/kubernetes/listers.go b/cluster-autoscaler/utils/kubernetes/listers.go index b70ca1db3ca4..d0033550fad8 100644 --- a/cluster-autoscaler/utils/kubernetes/listers.go +++ b/cluster-autoscaler/utils/kubernetes/listers.go @@ -22,14 +22,14 @@ import ( appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" apiv1 "k8s.io/api/core/v1" - policyv1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" client "k8s.io/client-go/kubernetes" v1appslister "k8s.io/client-go/listers/apps/v1" v1batchlister "k8s.io/client-go/listers/batch/v1" v1lister "k8s.io/client-go/listers/core/v1" - v1policylister "k8s.io/client-go/listers/policy/v1beta1" + v1policylister "k8s.io/client-go/listers/policy/v1" "k8s.io/client-go/tools/cache" podv1 "k8s.io/kubernetes/pkg/api/v1/pod" ) @@ -305,7 +305,7 @@ func (lister *PodDisruptionBudgetListerImpl) List() ([]*policyv1.PodDisruptionBu // NewPodDisruptionBudgetLister builds a pod disruption budget lister. func NewPodDisruptionBudgetLister(kubeClient client.Interface, stopchannel <-chan struct{}) PodDisruptionBudgetLister { - listWatcher := cache.NewListWatchFromClient(kubeClient.PolicyV1beta1().RESTClient(), "poddisruptionbudgets", apiv1.NamespaceAll, fields.Everything()) + listWatcher := cache.NewListWatchFromClient(kubeClient.PolicyV1().RESTClient(), "poddisruptionbudgets", apiv1.NamespaceAll, fields.Everything()) store, reflector := cache.NewNamespaceKeyedIndexerAndReflector(listWatcher, &policyv1.PodDisruptionBudget{}, time.Hour) pdbLister := v1policylister.NewPodDisruptionBudgetLister(store) go reflector.Run(stopchannel)