Skip to content

Commit efb0679

Browse files
authored
Merge pull request kubernetes-sigs#9547 from nawazkh/self_hosted_clusterclass
🌱 Dump all resource information for self-hosted tests
2 parents baf3f46 + de5302b commit efb0679

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

test/e2e/common.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,23 @@ func setupSpecNamespace(ctx context.Context, specName string, clusterProxy frame
6565
return namespace, cancelWatches
6666
}
6767

68-
func dumpSpecResourcesAndCleanup(ctx context.Context, specName string, clusterProxy framework.ClusterProxy, artifactFolder string, namespace *corev1.Namespace, cancelWatches context.CancelFunc, cluster *clusterv1.Cluster, intervalsGetter func(spec, key string) []interface{}, skipCleanup bool) {
68+
// dumpAllResources dumps all the resources in the spec namespace and the workload cluster.
69+
func dumpAllResources(ctx context.Context, clusterProxy framework.ClusterProxy, artifactFolder string, namespace *corev1.Namespace, cluster *clusterv1.Cluster) {
6970
Byf("Dumping logs from the %q workload cluster", cluster.Name)
7071

71-
// Dump all the logs from the workload cluster before deleting them.
72+
// Dump all the logs from the workload cluster.
7273
clusterProxy.CollectWorkloadClusterLogs(ctx, cluster.Namespace, cluster.Name, filepath.Join(artifactFolder, "clusters", cluster.Name))
7374

7475
Byf("Dumping all the Cluster API resources in the %q namespace", namespace.Name)
7576

76-
// Dump all Cluster API related resources to artifacts before deleting them.
77+
// Dump all Cluster API related resources to artifacts.
7778
framework.DumpAllResources(ctx, framework.DumpAllResourcesInput{
7879
Lister: clusterProxy.GetClient(),
7980
Namespace: namespace.Name,
8081
LogPath: filepath.Join(artifactFolder, "clusters", clusterProxy.GetName(), "resources"),
8182
})
8283

83-
// If the cluster still exists, dump pods and nodes of the workload cluster before deleting the cluster.
84+
// If the cluster still exists, dump pods and nodes of the workload cluster.
8485
if err := clusterProxy.GetClient().Get(ctx, client.ObjectKeyFromObject(cluster), &clusterv1.Cluster{}); err == nil {
8586
Byf("Dumping Pods and Nodes of Cluster %s", klog.KObj(cluster))
8687
framework.DumpResourcesForCluster(ctx, framework.DumpResourcesForClusterInput{
@@ -103,6 +104,12 @@ func dumpSpecResourcesAndCleanup(ctx context.Context, specName string, clusterPr
103104
},
104105
})
105106
}
107+
}
108+
109+
// dumpSpecResourcesAndCleanup dumps all the resources in the spec namespace and cleans up the spec namespace.
110+
func dumpSpecResourcesAndCleanup(ctx context.Context, specName string, clusterProxy framework.ClusterProxy, artifactFolder string, namespace *corev1.Namespace, cancelWatches context.CancelFunc, cluster *clusterv1.Cluster, intervalsGetter func(spec, key string) []interface{}, skipCleanup bool) {
111+
// Dump all the resources in the spec namespace and the workload cluster.
112+
dumpAllResources(ctx, clusterProxy, artifactFolder, namespace, cluster)
106113

107114
if !skipCleanup {
108115
Byf("Deleting cluster %s", klog.KObj(cluster))

test/e2e/self_hosted.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,7 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
391391
AfterEach(func() {
392392
if selfHostedNamespace != nil {
393393
// Dump all Cluster API related resources to artifacts before pivoting back.
394-
framework.DumpAllResources(ctx, framework.DumpAllResourcesInput{
395-
Lister: selfHostedClusterProxy.GetClient(),
396-
Namespace: namespace.Name,
397-
LogPath: filepath.Join(input.ArtifactFolder, "clusters", clusterResources.Cluster.Name, "resources"),
398-
})
394+
dumpAllResources(ctx, selfHostedClusterProxy, input.ArtifactFolder, namespace, clusterResources.Cluster)
399395
}
400396
if selfHostedCluster != nil {
401397
By("Ensure API servers are stable before doing move")

0 commit comments

Comments
 (0)