Skip to content

Commit 205af42

Browse files
committed
feat: check if cluster uses EMLB VIP manager before adding to EIP cleanup
Signed-off-by: Chris Privitere <23177737+cprivitere@users.noreply.github.com>
1 parent 829e766 commit 205af42

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

test/e2e/common_test.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
194208
func (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

Comments
 (0)