Skip to content

Commit 351faaf

Browse files
committed
test: Dump resources before deleting extensionconfig
1 parent 8aa545a commit 351faaf

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

test/e2e/cluster_upgrade_runtimesdk.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,31 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
298298
})
299299

300300
AfterEach(func() {
301-
// Delete the extensionConfig first to ensure the BeforeDeleteCluster hook doesn't block deletion.
302-
Eventually(func() error {
303-
return input.BootstrapClusterProxy.GetClient().Delete(ctx, extensionConfig(specName, namespace.Name, input.ExtensionServiceNamespace, input.ExtensionServiceName))
304-
}, 10*time.Second, 1*time.Second).Should(Succeed(), "delete extensionConfig failed")
305-
306-
// Dumps all the resources in the spec Namespace, then cleanups the cluster object and the spec Namespace itself.
307-
framework.DumpSpecResourcesAndCleanup(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder, namespace, cancelWatches, clusterResources.Cluster, input.E2EConfig.GetIntervals, input.SkipCleanup)
301+
// Dump all the resources in the spec namespace and the workload cluster.
302+
framework.DumpAllResourcesAndLogs(ctx, input.BootstrapClusterProxy, input.ArtifactFolder, namespace, clusterResources.Cluster)
303+
304+
if !input.SkipCleanup {
305+
// Delete the extensionConfig first to ensure the BeforeDeleteCluster hook doesn't block deletion.
306+
Eventually(func() error {
307+
return input.BootstrapClusterProxy.GetClient().Delete(ctx, extensionConfig(specName, namespace.Name, input.ExtensionServiceNamespace, input.ExtensionServiceName))
308+
}, 10*time.Second, 1*time.Second).Should(Succeed(), "delete extensionConfig failed")
309+
310+
Byf("Deleting cluster %s", klog.KObj(clusterResources.Cluster))
311+
// While https://github.com/kubernetes-sigs/cluster-api/issues/2955 is addressed in future iterations, there is a chance
312+
// that cluster variable is not set even if the cluster exists, so we are calling DeleteAllClustersAndWait
313+
// instead of DeleteClusterAndWait
314+
framework.DeleteAllClustersAndWait(ctx, framework.DeleteAllClustersAndWaitInput{
315+
Client: input.BootstrapClusterProxy.GetClient(),
316+
Namespace: namespace.Name,
317+
}, input.E2EConfig.GetIntervals(specName, "wait-delete-cluster")...)
318+
319+
Byf("Deleting namespace used for hosting the %q test spec", specName)
320+
framework.DeleteNamespace(ctx, framework.DeleteNamespaceInput{
321+
Deleter: input.BootstrapClusterProxy.GetClient(),
322+
Name: namespace.Name,
323+
})
324+
}
325+
cancelWatches()
308326
})
309327
}
310328

0 commit comments

Comments
 (0)