Skip to content

Commit f39025d

Browse files
Remove use of deprecated functions in VPA (#8904)
* Remove use of deprecated framework.WaitForServiceEndpointsNum * Remove use of deprecated NewSimpleClientset Only for upstream dependencies * Update vertical-pod-autoscaler/pkg/admission-controller/certs_test.go Co-authored-by: Erik Zilinsky <[email protected]> --------- Co-authored-by: Erik Zilinsky <[email protected]>
1 parent ff803d5 commit f39025d

File tree

8 files changed

+21
-24
lines changed

8 files changed

+21
-24
lines changed

vertical-pod-autoscaler/e2e/utils/webhook.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
clientset "k8s.io/client-go/kubernetes"
3838
"k8s.io/kubernetes/test/e2e/framework"
3939
e2edeploy "k8s.io/kubernetes/test/e2e/framework/deployment"
40+
e2eendpointslice "k8s.io/kubernetes/test/e2e/framework/endpointslice"
4041
"k8s.io/utils/ptr"
4142
)
4243

@@ -373,7 +374,7 @@ func DeployWebhookAndService(f *framework.Framework, image string, certContext *
373374
framework.ExpectNoError(err, "creating service %s in namespace %s", WebhookServiceName, namespace)
374375

375376
ginkgo.By("Verifying the service has paired with the endpoint")
376-
err = framework.WaitForServiceEndpointsNum(context.TODO(), client, namespace, WebhookServiceName, 1, 1*time.Second, 30*time.Second)
377+
err = e2eendpointslice.WaitForEndpointCount(context.TODO(), client, namespace, WebhookServiceName, 1)
377378
framework.ExpectNoError(err, "waiting for service %s/%s have %d endpoint", namespace, WebhookServiceName, 1)
378379
}
379380

vertical-pod-autoscaler/e2e/v1/autoscaling_utils.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
clientset "k8s.io/client-go/kubernetes"
3535
"k8s.io/kubernetes/test/e2e/framework"
3636
e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"
37+
e2eendpointslice "k8s.io/kubernetes/test/e2e/framework/endpointslice"
3738
e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
3839
e2erc "k8s.io/kubernetes/test/e2e/framework/rc"
3940
"k8s.io/kubernetes/test/e2e/framework/resource"
@@ -54,11 +55,6 @@ const (
5455
port = 80
5556
targetPort = 8080
5657
timeoutRC = 120 * time.Second
57-
startServiceTimeout = time.Minute
58-
startServiceInterval = 5 * time.Second
59-
rcIsNil = "ERROR: replicationController = nil"
60-
deploymentIsNil = "ERROR: deployment = nil"
61-
rsIsNil = "ERROR: replicaset = nil"
6258
invalidKind = "ERROR: invalid workload kind for resource consumer"
6359
customMetricName = "QPS"
6460
serviceInitializationTimeout = 2 * time.Minute
@@ -420,8 +416,8 @@ func runServiceAndWorkloadForResourceConsumer(c clientset.Interface, ns, name st
420416
framework.ExpectNoError(e2erc.RunRC(context.TODO(), controllerRcConfig))
421417

422418
// Wait for endpoints to propagate for the controller service.
423-
framework.ExpectNoError(framework.WaitForServiceEndpointsNum(
424-
context.TODO(), c, ns, controllerName, 1, startServiceInterval, startServiceTimeout))
419+
framework.ExpectNoError(e2eendpointslice.WaitForEndpointCount(
420+
context.TODO(), c, ns, controllerName, 1))
425421
}
426422

427423
// runReplicaSet launches (and verifies correctness) of a replicaset.

vertical-pod-autoscaler/pkg/admission-controller/certs_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func TestChangedCAReloader(t *testing.T) {
193193
t.Error(err)
194194
}
195195

196-
testClientSet := fake.NewSimpleClientset()
196+
testClientSet := fake.NewClientset()
197197

198198
selfRegistration(
199199
testClientSet,
@@ -309,7 +309,7 @@ func TestChangedCAReloader(t *testing.T) {
309309
// t.Error(err)
310310
// }
311311

312-
// testClientSet := fake.NewSimpleClientset()
312+
// testClientSet := fake.NewClientset()
313313

314314
// selfRegistration(
315315
// testClientSet,

vertical-pod-autoscaler/pkg/admission-controller/config_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
func TestSelfRegistrationBase(t *testing.T) {
3131

32-
testClientSet := fake.NewSimpleClientset()
32+
testClientSet := fake.NewClientset()
3333
caCert := []byte("fake")
3434
webHookDelay := 0 * time.Second
3535
namespace := "default"
@@ -73,7 +73,7 @@ func TestSelfRegistrationBase(t *testing.T) {
7373

7474
func TestSelfRegistrationWithURL(t *testing.T) {
7575

76-
testClientSet := fake.NewSimpleClientset()
76+
testClientSet := fake.NewClientset()
7777
caCert := []byte("fake")
7878
webHookDelay := 0 * time.Second
7979
namespace := "default"
@@ -101,7 +101,7 @@ func TestSelfRegistrationWithURL(t *testing.T) {
101101

102102
func TestSelfRegistrationWithOutURL(t *testing.T) {
103103

104-
testClientSet := fake.NewSimpleClientset()
104+
testClientSet := fake.NewClientset()
105105
caCert := []byte("fake")
106106
webHookDelay := 0 * time.Second
107107
namespace := "default"
@@ -131,7 +131,7 @@ func TestSelfRegistrationWithOutURL(t *testing.T) {
131131

132132
func TestSelfRegistrationWithIgnoredNamespaces(t *testing.T) {
133133

134-
testClientSet := fake.NewSimpleClientset()
134+
testClientSet := fake.NewClientset()
135135
caCert := []byte("fake")
136136
webHookDelay := 0 * time.Second
137137
namespace := "default"
@@ -162,7 +162,7 @@ func TestSelfRegistrationWithIgnoredNamespaces(t *testing.T) {
162162

163163
func TestSelfRegistrationWithSelectedNamespaces(t *testing.T) {
164164

165-
testClientSet := fake.NewSimpleClientset()
165+
testClientSet := fake.NewClientset()
166166
caCert := []byte("fake")
167167
webHookDelay := 0 * time.Second
168168
namespace := "default"
@@ -194,7 +194,7 @@ func TestSelfRegistrationWithSelectedNamespaces(t *testing.T) {
194194

195195
func TestSelfRegistrationWithFailurePolicy(t *testing.T) {
196196

197-
testClientSet := fake.NewSimpleClientset()
197+
testClientSet := fake.NewClientset()
198198
caCert := []byte("fake")
199199
webHookDelay := 0 * time.Second
200200
namespace := "default"
@@ -221,7 +221,7 @@ func TestSelfRegistrationWithFailurePolicy(t *testing.T) {
221221

222222
func TestSelfRegistrationWithOutFailurePolicy(t *testing.T) {
223223

224-
testClientSet := fake.NewSimpleClientset()
224+
testClientSet := fake.NewClientset()
225225
caCert := []byte("fake")
226226
webHookDelay := 0 * time.Second
227227
namespace := "default"
@@ -248,7 +248,7 @@ func TestSelfRegistrationWithOutFailurePolicy(t *testing.T) {
248248

249249
func TestSelfRegistrationWithInvalidLabels(t *testing.T) {
250250

251-
testClientSet := fake.NewSimpleClientset()
251+
testClientSet := fake.NewClientset()
252252
caCert := []byte("fake")
253253
webHookDelay := 0 * time.Second
254254
namespace := "default"

vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ func TestFilterVPAsIgnoreNamespaces(t *testing.T) {
858858

859859
func TestCanCleanupCheckpoints(t *testing.T) {
860860
_, tctx := ktesting.NewTestContext(t)
861-
client := fake.NewSimpleClientset()
861+
client := fake.NewClientset()
862862
namespace := "testNamespace"
863863

864864
_, err := client.CoreV1().Namespaces().Create(tctx, &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}}, metav1.CreateOptions{})

vertical-pod-autoscaler/pkg/updater/logic/updater_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func TestRunOnceIgnoreNamespaceMatching(t *testing.T) {
453453
}
454454

455455
func TestNewEventRecorder(t *testing.T) {
456-
fakeClient := fake.NewSimpleClientset()
456+
fakeClient := fake.NewClientset()
457457
er := newEventRecorder(fakeClient)
458458

459459
maxRetries := 5

vertical-pod-autoscaler/pkg/utils/limitrange/limit_range_calculator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestNewNoopLimitsChecker(t *testing.T) {
3838
}
3939

4040
func TestNoLimitRange(t *testing.T) {
41-
cs := fake.NewSimpleClientset()
41+
cs := fake.NewClientset()
4242
factory := informers.NewSharedInformerFactory(cs, 0)
4343
lc, err := NewLimitsRangeCalculator(factory)
4444

@@ -133,7 +133,7 @@ func TestGetContainerLimitRangeItem(t *testing.T) {
133133

134134
for _, tc := range testCases {
135135
t.Run(tc.name, func(t *testing.T) {
136-
cs := fake.NewSimpleClientset(tc.limitRanges...)
136+
cs := fake.NewClientset(tc.limitRanges...)
137137
factory := informers.NewSharedInformerFactory(cs, 0)
138138
lc, err := NewLimitsRangeCalculator(factory)
139139

vertical-pod-autoscaler/pkg/utils/status/status_object_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestUpdateStatus(t *testing.T) {
129129
}
130130
for _, tc := range tests {
131131
t.Run(fmt.Sprintf("test case: %s", tc.name), func(t *testing.T) {
132-
fc := fake.NewSimpleClientset()
132+
fc := fake.NewClientset()
133133
fc.PrependReactor("get", "leases", tc.updateReactor)
134134
fc.PrependReactor("create", "leases", tc.updateReactor)
135135
fc.PrependReactor("update", "leases", tc.updateReactor)
@@ -204,7 +204,7 @@ func TestGetStatus(t *testing.T) {
204204
}
205205
for _, tc := range tests {
206206
t.Run(fmt.Sprintf("test case: %s", tc.name), func(t *testing.T) {
207-
fc := fake.NewSimpleClientset()
207+
fc := fake.NewClientset()
208208
fc.PrependReactor("get", "leases", tc.getReactor)
209209
client := NewClient(fc, leaseName, leaseNamespace, 10*time.Second, leaseName)
210210
_, err := client.getStatus(context.Background())

0 commit comments

Comments
 (0)