From 6bd502d4c07add457325a40e116eadbdc3994219 Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Tue, 19 Nov 2024 13:52:42 +0100 Subject: [PATCH] Improve cluster deletion timeout message in e2e test framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Büringer buringerst@vmware.com --- test/framework/cluster_helpers.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/framework/cluster_helpers.go b/test/framework/cluster_helpers.go index 2387d55829a8..3a061687ecd7 100644 --- a/test/framework/cluster_helpers.go +++ b/test/framework/cluster_helpers.go @@ -18,6 +18,7 @@ package framework import ( "context" + "fmt" "path/filepath" . "github.com/onsi/ginkgo/v2" @@ -30,6 +31,7 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" . "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions" "sigs.k8s.io/cluster-api/test/framework/internal/log" + v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2" "sigs.k8s.io/cluster-api/util/patch" ) @@ -182,16 +184,23 @@ func WaitForClusterDeleted(ctx context.Context, input WaitForClusterDeletedInput }) } -func dumpArtifactsOnDeletionTimeout(ctx context.Context, client client.Client, cluster *clusterv1.Cluster, artifactFolder string) string { +func dumpArtifactsOnDeletionTimeout(ctx context.Context, c client.Client, cluster *clusterv1.Cluster, artifactFolder string) string { if artifactFolder != "" { // Dump all Cluster API related resources to artifacts. DumpAllResources(ctx, DumpAllResourcesInput{ - Lister: client, + Lister: c, Namespace: cluster.Namespace, LogPath: filepath.Join(artifactFolder, "clusters-afterDeletionTimedOut", cluster.Name, "resources"), }) } + // Try to get more details about why Cluster deletion timed out. + if err := c.Get(ctx, client.ObjectKeyFromObject(cluster), cluster); err == nil { + if c := v1beta2conditions.Get(cluster, clusterv1.MachineDeletingV1Beta2Condition); c != nil { + return fmt.Sprintf("waiting for cluster deletion timed out:\ncondition: %s\nmessage: %s", c.Type, c.Message) + } + } + return "waiting for cluster deletion timed out" }