@@ -66,13 +66,14 @@ func (wc *wrappedClient) IsObjectNamespaced(obj runtime.Object) (namespaced bool
6666type wrappedClusterProxy struct {
6767 clusterProxy framework.ClusterProxy
6868
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 ]
7071}
7172
7273func NewWrappedClusterProxy (name string , kubeconfigPath string , scheme * runtime.Scheme , options ... framework.Option ) * wrappedClusterProxy {
7374 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 ](),
7677 }
7778}
7879
@@ -236,7 +237,7 @@ func (w *wrappedClusterProxy) Dispose(ctx context.Context) {
236237 metalClient := packet .NewClient (metalAuthToken )
237238
238239 Eventually (func (g Gomega ) {
239- clusterNames := w .clusterNames .UnsortedList ()
240+ clusterNames := w .eipClusterNames .UnsortedList ()
240241 logf ("Will clean up EIPs for the following clusters: %v" , clusterNames )
241242
242243 for _ , clusterName := range clusterNames {
@@ -259,7 +260,7 @@ func (w *wrappedClusterProxy) Dispose(ctx context.Context) {
259260 Expect (err ).NotTo (HaveOccurred ())
260261 }, "5m" , "10s" ).Should (Succeed ())
261262
262- w .clusterNames .Delete (clusterName )
263+ w .eipClusterNames .Delete (clusterName )
263264 } else {
264265 logf ("EIP for cluster: %s with ID: %s appears to still be assigned" , clusterName , ipID )
265266 }
@@ -268,7 +269,7 @@ func (w *wrappedClusterProxy) Dispose(ctx context.Context) {
268269 }
269270 }
270271
271- g .Expect (w .clusterNames .UnsortedList ()).To (BeEmpty ())
272+ g .Expect (w .eipClusterNames .UnsortedList ()).To (BeEmpty ())
272273 }, "30m" , "1m" ).Should (Succeed ())
273274 }
274275
@@ -289,7 +290,7 @@ type wrappedClient struct {
289290 clusterProxy * wrappedClusterProxy
290291}
291292
292- func (wc * wrappedClient ) recordClusterNameForResource (obj client.Object ) error {
293+ func (wc * wrappedClient ) recordClusterNameForResource (ctx context. Context , obj client.Object ) error {
293294 var clusterName string
294295
295296 gvk , err := apiutil .GVKForObject (obj , wc .client .Scheme ())
@@ -307,15 +308,17 @@ func (wc *wrappedClient) recordClusterNameForResource(obj client.Object) error {
307308 }
308309
309310 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+ }
312315 }
313316
314317 return nil
315318}
316319
317320func (wc * wrappedClient ) Create (ctx context.Context , obj client.Object , opts ... client.CreateOption ) error {
318- err := wc .recordClusterNameForResource (obj )
321+ err := wc .recordClusterNameForResource (ctx , obj )
319322 if err != nil {
320323 return err
321324 }
@@ -324,29 +327,14 @@ func (wc *wrappedClient) Create(ctx context.Context, obj client.Object, opts ...
324327}
325328
326329func (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-
332330 return wc .client .Delete (ctx , obj , opts ... )
333331}
334332
335333func (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-
341334 return wc .client .Update (ctx , obj , opts ... )
342335}
343336
344337func (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-
350338 return wc .client .Patch (ctx , obj , patch , opts ... )
351339}
352340
@@ -356,11 +344,6 @@ func (wc *wrappedClient) DeleteAllOf(ctx context.Context, obj client.Object, opt
356344}
357345
358346func (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-
364347 return wc .client .Get (ctx , key , obj , opts ... )
365348}
366349
0 commit comments