@@ -23,7 +23,7 @@ import (
23
23
"time"
24
24
25
25
v1 "k8s.io/api/core/v1"
26
- networkingv1beta1 "k8s.io/api/networking/v1beta1 "
26
+ networkingv1 "k8s.io/api/networking/v1 "
27
27
apierrors "k8s.io/apimachinery/pkg/api/errors"
28
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29
29
"k8s.io/apimachinery/pkg/util/wait"
@@ -77,16 +77,16 @@ func TestMigrateServiceCIDR(t *testing.T) {
77
77
// ServiceCIDR controller
78
78
go servicecidrs .NewController (
79
79
tCtx ,
80
- informers1 .Networking ().V1beta1 ().ServiceCIDRs (),
81
- informers1 .Networking ().V1beta1 ().IPAddresses (),
80
+ informers1 .Networking ().V1 ().ServiceCIDRs (),
81
+ informers1 .Networking ().V1 ().IPAddresses (),
82
82
client1 ,
83
83
).Run (tCtx , 5 )
84
84
informers1 .Start (tCtx .Done ())
85
85
informers1 .WaitForCacheSync (tCtx .Done ())
86
86
87
87
// the default serviceCIDR should have a finalizer and ready condition set to true
88
88
if err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , time .Minute , false , func (ctx context.Context ) (bool , error ) {
89
- cidr , err := client1 .NetworkingV1beta1 ().ServiceCIDRs ().Get (context .TODO (), defaultservicecidr .DefaultServiceCIDRName , metav1.GetOptions {})
89
+ cidr , err := client1 .NetworkingV1 ().ServiceCIDRs ().Get (context .TODO (), defaultservicecidr .DefaultServiceCIDRName , metav1.GetOptions {})
90
90
if err != nil && ! apierrors .IsNotFound (err ) {
91
91
return false , err
92
92
}
@@ -120,13 +120,13 @@ func TestMigrateServiceCIDR(t *testing.T) {
120
120
}
121
121
}
122
122
// Add a new service CIDR to be able to migrate the apiserver
123
- if _ , err := client1 .NetworkingV1beta1 ().ServiceCIDRs ().Create (context .Background (), makeServiceCIDR ("migration-cidr" , cidr2 , "" ), metav1.CreateOptions {}); err != nil {
123
+ if _ , err := client1 .NetworkingV1 ().ServiceCIDRs ().Create (context .Background (), makeServiceCIDR ("migration-cidr" , cidr2 , "" ), metav1.CreateOptions {}); err != nil {
124
124
t .Fatalf ("got unexpected error: %v" , err )
125
125
}
126
126
127
127
// wait ServiceCIDR is ready
128
128
if err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , time .Minute , false , func (ctx context.Context ) (bool , error ) {
129
- cidr , err := client1 .NetworkingV1beta1 ().ServiceCIDRs ().Get (context .TODO (), "migration-cidr" , metav1.GetOptions {})
129
+ cidr , err := client1 .NetworkingV1 ().ServiceCIDRs ().Get (context .TODO (), "migration-cidr" , metav1.GetOptions {})
130
130
if err != nil && ! apierrors .IsNotFound (err ) {
131
131
return false , err
132
132
}
@@ -136,18 +136,18 @@ func TestMigrateServiceCIDR(t *testing.T) {
136
136
}
137
137
138
138
// delete the default ServiceCIDR so is no longer used for allocating IPs
139
- if err := client1 .NetworkingV1beta1 ().ServiceCIDRs ().Delete (context .Background (), defaultservicecidr .DefaultServiceCIDRName , metav1.DeleteOptions {}); err != nil {
139
+ if err := client1 .NetworkingV1 ().ServiceCIDRs ().Delete (context .Background (), defaultservicecidr .DefaultServiceCIDRName , metav1.DeleteOptions {}); err != nil {
140
140
t .Fatalf ("got unexpected error: %v" , err )
141
141
}
142
142
143
143
// the default serviceCIDR should be pending deletion with Ready condition set to false
144
144
if err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , time .Minute , false , func (ctx context.Context ) (bool , error ) {
145
- cidr , err := client1 .NetworkingV1beta1 ().ServiceCIDRs ().Get (context .TODO (), defaultservicecidr .DefaultServiceCIDRName , metav1.GetOptions {})
145
+ cidr , err := client1 .NetworkingV1 ().ServiceCIDRs ().Get (context .TODO (), defaultservicecidr .DefaultServiceCIDRName , metav1.GetOptions {})
146
146
if err != nil && ! apierrors .IsNotFound (err ) {
147
147
return false , err
148
148
}
149
149
for _ , condition := range cidr .Status .Conditions {
150
- if condition .Type == networkingv1beta1 .ServiceCIDRConditionReady {
150
+ if condition .Type == networkingv1 .ServiceCIDRConditionReady {
151
151
return condition .Status == metav1 .ConditionFalse , nil
152
152
}
153
153
}
@@ -216,8 +216,8 @@ func TestMigrateServiceCIDR(t *testing.T) {
216
216
informers2 := informers .NewSharedInformerFactory (client2 , resyncPeriod )
217
217
go servicecidrs .NewController (
218
218
tCtx2 ,
219
- informers2 .Networking ().V1beta1 ().ServiceCIDRs (),
220
- informers2 .Networking ().V1beta1 ().IPAddresses (),
219
+ informers2 .Networking ().V1 ().ServiceCIDRs (),
220
+ informers2 .Networking ().V1 ().IPAddresses (),
221
221
client2 ,
222
222
).Run (tCtx2 , 5 )
223
223
informers2 .Start (tCtx2 .Done ())
@@ -231,7 +231,7 @@ func TestMigrateServiceCIDR(t *testing.T) {
231
231
232
232
// the default serviceCIDR should be the new one
233
233
if err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , time .Minute , false , func (ctx context.Context ) (bool , error ) {
234
- cidr , err := client2 .NetworkingV1beta1 ().ServiceCIDRs ().Get (context .TODO (), defaultservicecidr .DefaultServiceCIDRName , metav1.GetOptions {})
234
+ cidr , err := client2 .NetworkingV1 ().ServiceCIDRs ().Get (context .TODO (), defaultservicecidr .DefaultServiceCIDRName , metav1.GetOptions {})
235
235
if err != nil && ! apierrors .IsNotFound (err ) {
236
236
return false , err
237
237
}
@@ -252,7 +252,7 @@ func TestMigrateServiceCIDR(t *testing.T) {
252
252
}
253
253
254
254
for _ , condition := range cidr .Status .Conditions {
255
- if condition .Type == networkingv1beta1 .ServiceCIDRConditionReady {
255
+ if condition .Type == networkingv1 .ServiceCIDRConditionReady {
256
256
t .Logf ("Expected Condition %s to be %s" , condition .Status , metav1 .ConditionTrue )
257
257
return condition .Status == metav1 .ConditionTrue , nil
258
258
}
@@ -277,13 +277,13 @@ func TestMigrateServiceCIDR(t *testing.T) {
277
277
}
278
278
279
279
// The temporary ServiceCIDR can be deleted now since the Default ServiceCIDR will cover it
280
- if err := client2 .NetworkingV1beta1 ().ServiceCIDRs ().Delete (context .Background (), "migration-cidr" , metav1.DeleteOptions {}); err != nil {
280
+ if err := client2 .NetworkingV1 ().ServiceCIDRs ().Delete (context .Background (), "migration-cidr" , metav1.DeleteOptions {}); err != nil {
281
281
t .Fatalf ("got unexpected error: %v" , err )
282
282
}
283
283
284
284
// wait ServiceCIDR no longer exist
285
285
if err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , time .Minute , false , func (ctx context.Context ) (bool , error ) {
286
- _ , err := client2 .NetworkingV1beta1 ().ServiceCIDRs ().Get (context .TODO (), "migration-cidr" , metav1.GetOptions {})
286
+ _ , err := client2 .NetworkingV1 ().ServiceCIDRs ().Get (context .TODO (), "migration-cidr" , metav1.GetOptions {})
287
287
if err != nil && ! apierrors .IsNotFound (err ) {
288
288
return false , nil
289
289
}
0 commit comments