@@ -38,6 +38,7 @@ import (
3838 "k8s.io/client-go/rest"
3939 "k8s.io/client-go/tools/clientcmd"
4040 "k8s.io/client-go/tools/clientcmd/api"
41+ infrav1 "sigs.k8s.io/cluster-api-provider-packet/api/v1beta1"
4142 "sigs.k8s.io/cluster-api-provider-packet/pkg/cloud/packet"
4243 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
4344 "sigs.k8s.io/cluster-api/test/framework"
@@ -191,6 +192,19 @@ func (w *wrappedClusterProxy) isDockerCluster(ctx context.Context, namespace str
191192 return cluster .Spec .InfrastructureRef .Kind == "DockerCluster"
192193}
193194
195+ func (w * wrappedClusterProxy ) isEMLBCluster (ctx context.Context , namespace string , name string ) bool {
196+ cl := w .GetClient ()
197+
198+ packetCluster := & infrav1.PacketCluster {}
199+ key := client.ObjectKey {
200+ Name : name ,
201+ Namespace : namespace ,
202+ }
203+ Expect (cl .Get (ctx , key , packetCluster )).To (Succeed (), "Failed to get %s" , key )
204+
205+ return packetCluster .Spec .VIPManager == "EMLB"
206+ }
207+
194208func (w * wrappedClusterProxy ) getKubeconfig (ctx context.Context , namespace string , name string ) * api.Config {
195209 cl := w .GetClient ()
196210
@@ -358,8 +372,10 @@ func (wc *wrappedClient) List(ctx context.Context, list client.ObjectList, opts
358372
359373 if cl , ok := list .(* clusterv1.ClusterList ); ok {
360374 for _ , c := range cl .Items {
361- logf ("Recording cluster %s for EIP Cleanup later" , c .GetName ())
362- wc .clusterProxy .clusterNames .Insert (c .GetName ())
375+ if ! wc .clusterProxy .isEMLBCluster (ctx , c .Namespace , c .GetName ()) {
376+ logf ("Recording cluster %s for EIP Cleanup later" , c .GetName ())
377+ wc .clusterProxy .clusterNames .Insert (c .GetName ())
378+ }
363379 }
364380 }
365381
0 commit comments