Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Dump all resource information for self-hosted tests #9547

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,23 @@ func setupSpecNamespace(ctx context.Context, specName string, clusterProxy frame
return namespace, cancelWatches
}

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) {
// dumpAllResources dumps all the resources in the spec namespace and the workload cluster.
func dumpAllResources(ctx context.Context, clusterProxy framework.ClusterProxy, artifactFolder string, namespace *corev1.Namespace, cluster *clusterv1.Cluster) {
Byf("Dumping logs from the %q workload cluster", cluster.Name)

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

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

// Dump all Cluster API related resources to artifacts before deleting them.
// Dump all Cluster API related resources to artifacts.
framework.DumpAllResources(ctx, framework.DumpAllResourcesInput{
Lister: clusterProxy.GetClient(),
Namespace: namespace.Name,
LogPath: filepath.Join(artifactFolder, "clusters", clusterProxy.GetName(), "resources"),
})

// If the cluster still exists, dump pods and nodes of the workload cluster before deleting the cluster.
// If the cluster still exists, dump pods and nodes of the workload cluster.
if err := clusterProxy.GetClient().Get(ctx, client.ObjectKeyFromObject(cluster), &clusterv1.Cluster{}); err == nil {
Byf("Dumping Pods and Nodes of Cluster %s", klog.KObj(cluster))
framework.DumpResourcesForCluster(ctx, framework.DumpResourcesForClusterInput{
Expand All @@ -103,6 +104,12 @@ func dumpSpecResourcesAndCleanup(ctx context.Context, specName string, clusterPr
},
})
}
}

// dumpSpecResourcesAndCleanup dumps all the resources in the spec namespace and cleans up the spec namespace.
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) {
// Dump all the resources in the spec namespace and the workload cluster.
dumpAllResources(ctx, clusterProxy, artifactFolder, namespace, cluster)

if !skipCleanup {
Byf("Deleting cluster %s", klog.KObj(cluster))
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/self_hosted.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,7 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
AfterEach(func() {
if selfHostedNamespace != nil {
// Dump all Cluster API related resources to artifacts before pivoting back.
framework.DumpAllResources(ctx, framework.DumpAllResourcesInput{
Lister: selfHostedClusterProxy.GetClient(),
Namespace: namespace.Name,
LogPath: filepath.Join(input.ArtifactFolder, "clusters", clusterResources.Cluster.Name, "resources"),
})
dumpAllResources(ctx, selfHostedClusterProxy, input.ArtifactFolder, namespace, clusterResources.Cluster)
}
if selfHostedCluster != nil {
By("Ensure API servers are stable before doing move")
Expand Down
Loading