@@ -183,6 +183,33 @@ func TestEnsureLoadBalancerDeletedDeletesInternalLb(t *testing.T) {
183
183
assertInternalLbResourcesDeleted (t , gce , apiService , vals , true )
184
184
}
185
185
186
+ func TestEnsureLoadBalancerDeletedChecksInternalLbFinalizer (t * testing.T ) {
187
+ t .Parallel ()
188
+
189
+ vals := DefaultTestClusterValues ()
190
+ gce , err := fakeGCECloud (vals )
191
+ require .NoError (t , err )
192
+
193
+ nodeNames := []string {"test-node-1" }
194
+ _ , err = createAndInsertNodes (gce , nodeNames , vals .ZoneName )
195
+ require .NoError (t , err )
196
+
197
+ apiService := fakeLoadbalancerService (string (LBTypeInternal ))
198
+ apiService , err = gce .client .CoreV1 ().Services (apiService .Namespace ).Create (context .TODO (), apiService , metav1.CreateOptions {})
199
+ require .NoError (t , err )
200
+ createInternalLoadBalancer (gce , apiService , nil , nodeNames , vals .ClusterName , vals .ClusterID , vals .ZoneName )
201
+
202
+ // Read service from apiserver so it has finalizer
203
+ apiService , err = gce .client .CoreV1 ().Services (apiService .Namespace ).Get (context .TODO (), apiService .Name , metav1.GetOptions {})
204
+ if err != nil {
205
+ t .Fatalf ("Unexpected error: %v" , err )
206
+ }
207
+ delete (apiService .Annotations , ServiceAnnotationLoadBalancerType )
208
+ err = gce .EnsureLoadBalancerDeleted (context .Background (), vals .ClusterName , apiService )
209
+ assert .NoError (t , err )
210
+ assertInternalLbResourcesDeleted (t , gce , apiService , vals , true )
211
+ }
212
+
186
213
func TestProjectsBasePath (t * testing.T ) {
187
214
t .Parallel ()
188
215
vals := DefaultTestClusterValues ()
0 commit comments