Skip to content

Commit 5a9d42b

Browse files
authored
Merge pull request #8142 from sbueringer/pr-improve-e2e-res-dump
🌱 test/framework: ensure ApplyClusterTemplateAndWait always returns a cluster
2 parents 6887f96 + 8838eca commit 5a9d42b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/framework/clusterctl/clusterctl_helpers.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"time"
2424

2525
. "github.com/onsi/gomega"
26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2627

2728
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2829
"sigs.k8s.io/cluster-api/cmd/clusterctl/client/config"
@@ -274,6 +275,14 @@ func ApplyClusterTemplateAndWait(ctx context.Context, input ApplyClusterTemplate
274275
log.Logf("Creating the workload cluster with name %q using the %q template (Kubernetes %s, %d control-plane machines, %d worker machines)",
275276
input.ConfigCluster.ClusterName, valueOrDefault(input.ConfigCluster.Flavor), input.ConfigCluster.KubernetesVersion, *input.ConfigCluster.ControlPlaneMachineCount, *input.ConfigCluster.WorkerMachineCount)
276277

278+
// Ensure we have a Cluster for dump and cleanup steps in AfterEach even if ApplyClusterTemplateAndWait fails.
279+
result.Cluster = &clusterv1.Cluster{
280+
ObjectMeta: metav1.ObjectMeta{
281+
Name: input.ConfigCluster.ClusterName,
282+
Namespace: input.ConfigCluster.Namespace,
283+
},
284+
}
285+
277286
log.Logf("Getting the cluster template yaml")
278287
workloadClusterTemplate := ConfigCluster(ctx, ConfigClusterInput{
279288
// pass reference to the management cluster hosting this test

0 commit comments

Comments
 (0)