@@ -18,6 +18,7 @@ package framework
18
18
19
19
import (
20
20
"context"
21
+ "fmt"
21
22
"path/filepath"
22
23
23
24
. "github.com/onsi/ginkgo/v2"
@@ -30,6 +31,7 @@ import (
30
31
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
31
32
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
32
33
"sigs.k8s.io/cluster-api/test/framework/internal/log"
34
+ v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
33
35
"sigs.k8s.io/cluster-api/util/patch"
34
36
)
35
37
@@ -182,16 +184,23 @@ func WaitForClusterDeleted(ctx context.Context, input WaitForClusterDeletedInput
182
184
})
183
185
}
184
186
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 {
186
188
if artifactFolder != "" {
187
189
// Dump all Cluster API related resources to artifacts.
188
190
DumpAllResources (ctx , DumpAllResourcesInput {
189
- Lister : client ,
191
+ Lister : c ,
190
192
Namespace : cluster .Namespace ,
191
193
LogPath : filepath .Join (artifactFolder , "clusters-afterDeletionTimedOut" , cluster .Name , "resources" ),
192
194
})
193
195
}
194
196
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:\n condition: %s\n message: %s" , c .Type , c .Message )
201
+ }
202
+ }
203
+
195
204
return "waiting for cluster deletion timed out"
196
205
}
197
206
0 commit comments