From aceb96667b7b14d89cbd1d3d7c0ced10537ce0a1 Mon Sep 17 00:00:00 2001 From: Nam Xuan Nguyen Date: Fri, 31 Dec 2021 11:59:29 +0200 Subject: [PATCH] Add timeout to check if KCP object exists --- test/framework/controlplane_helpers.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/framework/controlplane_helpers.go b/test/framework/controlplane_helpers.go index 9fc569ab4524..add19f1e7e23 100644 --- a/test/framework/controlplane_helpers.go +++ b/test/framework/controlplane_helpers.go @@ -228,12 +228,15 @@ func DiscoveryAndWaitForControlPlaneInitialized(ctx context.Context, input Disco Expect(input.Lister).ToNot(BeNil(), "Invalid argument. input.Lister can't be nil when calling DiscoveryAndWaitForControlPlaneInitialized") Expect(input.Cluster).ToNot(BeNil(), "Invalid argument. input.Cluster can't be nil when calling DiscoveryAndWaitForControlPlaneInitialized") - controlPlane := GetKubeadmControlPlaneByCluster(ctx, GetKubeadmControlPlaneByClusterInput{ - Lister: input.Lister, - ClusterName: input.Cluster.Name, - Namespace: input.Cluster.Namespace, - }) - Expect(controlPlane).ToNot(BeNil()) + var controlPlane *controlplanev1.KubeadmControlPlane + Eventually(func(g Gomega) { + controlPlane = GetKubeadmControlPlaneByCluster(ctx, GetKubeadmControlPlaneByClusterInput{ + Lister: input.Lister, + ClusterName: input.Cluster.Name, + Namespace: input.Cluster.Namespace, + }) + g.Expect(controlPlane).ToNot(BeNil()) + }, "5s", "1s").Should(Succeed()) log.Logf("Waiting for the first control plane machine managed by %s/%s to be provisioned", controlPlane.Namespace, controlPlane.Name) WaitForOneKubeadmControlPlaneMachineToExist(ctx, WaitForOneKubeadmControlPlaneMachineToExistInput{