@@ -66,13 +66,14 @@ func (wc *wrappedClient) IsObjectNamespaced(obj runtime.Object) (namespaced bool
66
66
type wrappedClusterProxy struct {
67
67
clusterProxy framework.ClusterProxy
68
68
69
- clusterNames sets.Set [string ]
69
+ // This is a list of cluster names that have EIPs that need to be disposed of.
70
+ eipClusterNames sets.Set [string ]
70
71
}
71
72
72
73
func NewWrappedClusterProxy (name string , kubeconfigPath string , scheme * runtime.Scheme , options ... framework.Option ) * wrappedClusterProxy {
73
74
return & wrappedClusterProxy {
74
- clusterProxy : framework .NewClusterProxy (name , kubeconfigPath , scheme , options ... ),
75
- clusterNames : sets .New [string ](),
75
+ clusterProxy : framework .NewClusterProxy (name , kubeconfigPath , scheme , options ... ),
76
+ eipClusterNames : sets .New [string ](),
76
77
}
77
78
}
78
79
@@ -236,7 +237,7 @@ func (w *wrappedClusterProxy) Dispose(ctx context.Context) {
236
237
metalClient := packet .NewClient (metalAuthToken )
237
238
238
239
Eventually (func (g Gomega ) {
239
- clusterNames := w .clusterNames .UnsortedList ()
240
+ clusterNames := w .eipClusterNames .UnsortedList ()
240
241
logf ("Will clean up EIPs for the following clusters: %v" , clusterNames )
241
242
242
243
for _ , clusterName := range clusterNames {
@@ -259,7 +260,7 @@ func (w *wrappedClusterProxy) Dispose(ctx context.Context) {
259
260
Expect (err ).NotTo (HaveOccurred ())
260
261
}, "5m" , "10s" ).Should (Succeed ())
261
262
262
- w .clusterNames .Delete (clusterName )
263
+ w .eipClusterNames .Delete (clusterName )
263
264
} else {
264
265
logf ("EIP for cluster: %s with ID: %s appears to still be assigned" , clusterName , ipID )
265
266
}
@@ -268,7 +269,7 @@ func (w *wrappedClusterProxy) Dispose(ctx context.Context) {
268
269
}
269
270
}
270
271
271
- g .Expect (w .clusterNames .UnsortedList ()).To (BeEmpty ())
272
+ g .Expect (w .eipClusterNames .UnsortedList ()).To (BeEmpty ())
272
273
}, "30m" , "1m" ).Should (Succeed ())
273
274
}
274
275
@@ -289,7 +290,7 @@ type wrappedClient struct {
289
290
clusterProxy * wrappedClusterProxy
290
291
}
291
292
292
- func (wc * wrappedClient ) recordClusterNameForResource (obj client.Object ) error {
293
+ func (wc * wrappedClient ) recordClusterNameForResource (ctx context. Context , obj client.Object ) error {
293
294
var clusterName string
294
295
295
296
gvk , err := apiutil .GVKForObject (obj , wc .client .Scheme ())
@@ -307,15 +308,17 @@ func (wc *wrappedClient) recordClusterNameForResource(obj client.Object) error {
307
308
}
308
309
309
310
if clusterName != "" {
310
- logf ("Recording cluster %s for EIP Cleanup later" , clusterName )
311
- wc .clusterProxy .clusterNames .Insert (clusterName )
311
+ if ! wc .clusterProxy .isEMLBCluster (ctx , obj .GetName (), clusterName ) {
312
+ logf ("Recording cluster %s for EIP Cleanup later" , clusterName )
313
+ wc .clusterProxy .eipClusterNames .Insert (clusterName )
314
+ }
312
315
}
313
316
314
317
return nil
315
318
}
316
319
317
320
func (wc * wrappedClient ) Create (ctx context.Context , obj client.Object , opts ... client.CreateOption ) error {
318
- err := wc .recordClusterNameForResource (obj )
321
+ err := wc .recordClusterNameForResource (ctx , obj )
319
322
if err != nil {
320
323
return err
321
324
}
@@ -324,29 +327,14 @@ func (wc *wrappedClient) Create(ctx context.Context, obj client.Object, opts ...
324
327
}
325
328
326
329
func (wc * wrappedClient ) Delete (ctx context.Context , obj client.Object , opts ... client.DeleteOption ) error {
327
- err := wc .recordClusterNameForResource (obj )
328
- if err != nil {
329
- return err
330
- }
331
-
332
330
return wc .client .Delete (ctx , obj , opts ... )
333
331
}
334
332
335
333
func (wc * wrappedClient ) Update (ctx context.Context , obj client.Object , opts ... client.UpdateOption ) error {
336
- err := wc .recordClusterNameForResource (obj )
337
- if err != nil {
338
- return err
339
- }
340
-
341
334
return wc .client .Update (ctx , obj , opts ... )
342
335
}
343
336
344
337
func (wc * wrappedClient ) Patch (ctx context.Context , obj client.Object , patch client.Patch , opts ... client.PatchOption ) error {
345
- err := wc .recordClusterNameForResource (obj )
346
- if err != nil {
347
- return err
348
- }
349
-
350
338
return wc .client .Patch (ctx , obj , patch , opts ... )
351
339
}
352
340
@@ -356,11 +344,6 @@ func (wc *wrappedClient) DeleteAllOf(ctx context.Context, obj client.Object, opt
356
344
}
357
345
358
346
func (wc * wrappedClient ) Get (ctx context.Context , key client.ObjectKey , obj client.Object , opts ... client.GetOption ) error {
359
- err := wc .recordClusterNameForResource (obj )
360
- if err != nil {
361
- return err
362
- }
363
-
364
347
return wc .client .Get (ctx , key , obj , opts ... )
365
348
}
366
349
0 commit comments