Skip to content

Commit 56e5338

Browse files
authored
Merge pull request #11444 from sbueringer/pr-improve-wait-timeout
🌱 Improve cluster deletion timeout message in e2e test framework
2 parents 2a66b18 + 6bd502d commit 56e5338

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/framework/cluster_helpers.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package framework
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"path/filepath"
2223

2324
. "github.com/onsi/ginkgo/v2"
@@ -30,6 +31,7 @@ import (
3031
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3132
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
3233
"sigs.k8s.io/cluster-api/test/framework/internal/log"
34+
v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
3335
"sigs.k8s.io/cluster-api/util/patch"
3436
)
3537

@@ -182,16 +184,23 @@ func WaitForClusterDeleted(ctx context.Context, input WaitForClusterDeletedInput
182184
})
183185
}
184186

185-
func dumpArtifactsOnDeletionTimeout(ctx context.Context, client client.Client, cluster *clusterv1.Cluster, artifactFolder string) string {
187+
func dumpArtifactsOnDeletionTimeout(ctx context.Context, c client.Client, cluster *clusterv1.Cluster, artifactFolder string) string {
186188
if artifactFolder != "" {
187189
// Dump all Cluster API related resources to artifacts.
188190
DumpAllResources(ctx, DumpAllResourcesInput{
189-
Lister: client,
191+
Lister: c,
190192
Namespace: cluster.Namespace,
191193
LogPath: filepath.Join(artifactFolder, "clusters-afterDeletionTimedOut", cluster.Name, "resources"),
192194
})
193195
}
194196

197+
// Try to get more details about why Cluster deletion timed out.
198+
if err := c.Get(ctx, client.ObjectKeyFromObject(cluster), cluster); err == nil {
199+
if c := v1beta2conditions.Get(cluster, clusterv1.MachineDeletingV1Beta2Condition); c != nil {
200+
return fmt.Sprintf("waiting for cluster deletion timed out:\ncondition: %s\nmessage: %s", c.Type, c.Message)
201+
}
202+
}
203+
195204
return "waiting for cluster deletion timed out"
196205
}
197206

0 commit comments

Comments
 (0)