Skip to content

Commit

Permalink
Merge pull request #11444 from sbueringer/pr-improve-wait-timeout
Browse files Browse the repository at this point in the history
🌱 Improve cluster deletion timeout message in e2e test framework
  • Loading branch information
k8s-ci-robot authored Nov 19, 2024
2 parents 2a66b18 + 6bd502d commit 56e5338
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/framework/cluster_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package framework

import (
"context"
"fmt"
"path/filepath"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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"
}

Expand Down

0 comments on commit 56e5338

Please sign in to comment.