From e85157b68450ab0af9c481d0f76e25463f85057a Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Fri, 7 Jul 2023 10:31:22 +0200 Subject: [PATCH] chore: Change order of how resources get dumped Dump CamelCatalog at the end to avoid heavy log scrolling during failure analysis --- e2e/support/util/dump.go | 82 ++++++++++++++++++++-------------------- pkg/cmd/dump.go | 59 ++++++++++++++++------------- 2 files changed, 74 insertions(+), 67 deletions(-) diff --git a/e2e/support/util/dump.go b/e2e/support/util/dump.go index 741cba2b79..1b7a0d6c25 100644 --- a/e2e/support/util/dump.go +++ b/e2e/support/util/dump.go @@ -52,14 +52,14 @@ func Dump(ctx context.Context, c client.Client, ns string, t *testing.T) error { return err } - // IntegrationPlatforms - pls, err := camelClient.CamelV1().IntegrationPlatforms(ns).List(ctx, metav1.ListOptions{}) + // Integrations + its, err := camelClient.CamelV1().Integrations(ns).List(ctx, metav1.ListOptions{}) if err != nil { return err } - t.Logf("Found %d platforms:\n", len(pls.Items)) - for _, p := range pls.Items { - ref := p + t.Logf("Found %d integrations:\n", len(its.Items)) + for _, integration := range its.Items { + ref := integration pdata, err := kubernetes.ToYAMLNoManagedFields(&ref) if err != nil { return err @@ -67,35 +67,6 @@ func Dump(ctx context.Context, c client.Client, ns string, t *testing.T) error { t.Logf("---\n%s\n---\n", string(pdata)) } - // CamelCatalogs - cats, err := camelClient.CamelV1().CamelCatalogs(ns).List(ctx, metav1.ListOptions{}) - if err != nil { - return err - } - t.Logf("Found %d catalogs:\n", len(cats.Items)) - for _, c := range cats.Items { - ref := c - cdata, err := kubernetes.ToYAMLNoManagedFields(&ref) - if err != nil { - return err - } - t.Logf("---\n%s\n---\n", string(cdata)) - } - - // Builds - builds, err := camelClient.CamelV1().Builds(ns).List(ctx, metav1.ListOptions{}) - if err != nil { - return err - } - t.Logf("Found %d builds:\n", len(builds.Items)) - for _, build := range builds.Items { - data, err := kubernetes.ToYAMLNoManagedFields(&build) - if err != nil { - return err - } - t.Logf("---\n%s\n---\n", string(data)) - } - // IntegrationKits iks, err := camelClient.CamelV1().IntegrationKits(ns).List(ctx, metav1.ListOptions{}) if err != nil { @@ -111,19 +82,18 @@ func Dump(ctx context.Context, c client.Client, ns string, t *testing.T) error { t.Logf("---\n%s\n---\n", string(pdata)) } - // Integrations - its, err := camelClient.CamelV1().Integrations(ns).List(ctx, metav1.ListOptions{}) + // Builds + builds, err := camelClient.CamelV1().Builds(ns).List(ctx, metav1.ListOptions{}) if err != nil { return err } - t.Logf("Found %d integrations:\n", len(its.Items)) - for _, integration := range its.Items { - ref := integration - pdata, err := kubernetes.ToYAMLNoManagedFields(&ref) + t.Logf("Found %d builds:\n", len(builds.Items)) + for _, build := range builds.Items { + data, err := kubernetes.ToYAMLNoManagedFields(&build) if err != nil { return err } - t.Logf("---\n%s\n---\n", string(pdata)) + t.Logf("---\n%s\n---\n", string(data)) } // Configmaps @@ -203,6 +173,36 @@ func Dump(ctx context.Context, c client.Client, ns string, t *testing.T) error { } } + // IntegrationPlatforms + pls, err := camelClient.CamelV1().IntegrationPlatforms(ns).List(ctx, metav1.ListOptions{}) + if err != nil { + return err + } + t.Logf("Found %d platforms:\n", len(pls.Items)) + for _, p := range pls.Items { + ref := p + pdata, err := kubernetes.ToYAMLNoManagedFields(&ref) + if err != nil { + return err + } + t.Logf("---\n%s\n---\n", string(pdata)) + } + + // CamelCatalogs + cats, err := camelClient.CamelV1().CamelCatalogs(ns).List(ctx, metav1.ListOptions{}) + if err != nil { + return err + } + t.Logf("Found %d catalogs:\n", len(cats.Items)) + for _, c := range cats.Items { + ref := c + cdata, err := kubernetes.ToYAMLNoManagedFields(&ref) + if err != nil { + return err + } + t.Logf("---\n%s\n---\n", string(cdata)) + } + // Services svcs, err := c.CoreV1().Services(ns).List(ctx, metav1.ListOptions{}) if err != nil { diff --git a/pkg/cmd/dump.go b/pkg/cmd/dump.go index 77c64d0b7a..b67637f692 100644 --- a/pkg/cmd/dump.go +++ b/pkg/cmd/dump.go @@ -90,6 +90,7 @@ func dumpNamespace(ctx context.Context, c client.Client, ns string, out io.Write return err } + // Integrations its, err := camelClient.CamelV1().Integrations(ns).List(ctx, metav1.ListOptions{}) if err != nil { return err @@ -104,13 +105,14 @@ func dumpNamespace(ctx context.Context, c client.Client, ns string, out io.Write fmt.Fprintf(out, "---\n%s\n---\n", string(pdata)) } - pls, err := camelClient.CamelV1().IntegrationPlatforms(ns).List(ctx, metav1.ListOptions{}) + // IntegrationKits + iks, err := camelClient.CamelV1().IntegrationKits(ns).List(ctx, metav1.ListOptions{}) if err != nil { return err } - fmt.Fprintf(out, "Found %d platforms:\n", len(pls.Items)) - for _, p := range pls.Items { - ref := p + fmt.Fprintf(out, "Found %d integration kits:\n", len(iks.Items)) + for _, ik := range iks.Items { + ref := ik pdata, err := kubernetes.ToYAML(&ref) if err != nil { return err @@ -118,41 +120,44 @@ func dumpNamespace(ctx context.Context, c client.Client, ns string, out io.Write fmt.Fprintf(out, "---\n%s\n---\n", string(pdata)) } - cat, err := camelClient.CamelV1().CamelCatalogs(ns).List(ctx, metav1.ListOptions{}) + // ConfigMaps + cms, err := c.CoreV1().ConfigMaps(ns).List(ctx, metav1.ListOptions{}) if err != nil { return err } - fmt.Fprintf(out, "Found %d catalogs:\n", len(pls.Items)) - for _, c := range cat.Items { - ref := c - cdata, err := kubernetes.ToYAML(&ref) + fmt.Fprintf(out, "Found %d ConfigMaps:\n", len(cms.Items)) + for _, cm := range cms.Items { + ref := cm + pdata, err := kubernetes.ToYAML(&ref) if err != nil { return err } - fmt.Fprintf(out, "---\n%s\n---\n", string(cdata)) + fmt.Fprintf(out, "---\n%s\n---\n", string(pdata)) } - iks, err := camelClient.CamelV1().IntegrationKits(ns).List(ctx, metav1.ListOptions{}) + // Deployments + deployments, err := c.AppsV1().Deployments(ns).List(ctx, metav1.ListOptions{}) if err != nil { return err } - fmt.Fprintf(out, "Found %d integration kits:\n", len(iks.Items)) - for _, ik := range iks.Items { - ref := ik - pdata, err := kubernetes.ToYAML(&ref) + fmt.Fprintf(out, "Found %d deployments:\n", len(deployments.Items)) + for _, deployment := range deployments.Items { + ref := deployment + data, err := kubernetes.ToYAML(&ref) if err != nil { return err } - fmt.Fprintf(out, "---\n%s\n---\n", string(pdata)) + fmt.Fprintf(out, "---\n%s\n---\n", string(data)) } - cms, err := c.CoreV1().ConfigMaps(ns).List(ctx, metav1.ListOptions{}) + // IntegrationPlatforms + pls, err := camelClient.CamelV1().IntegrationPlatforms(ns).List(ctx, metav1.ListOptions{}) if err != nil { return err } - fmt.Fprintf(out, "Found %d ConfigMaps:\n", len(cms.Items)) - for _, cm := range cms.Items { - ref := cm + fmt.Fprintf(out, "Found %d platforms:\n", len(pls.Items)) + for _, p := range pls.Items { + ref := p pdata, err := kubernetes.ToYAML(&ref) if err != nil { return err @@ -160,20 +165,22 @@ func dumpNamespace(ctx context.Context, c client.Client, ns string, out io.Write fmt.Fprintf(out, "---\n%s\n---\n", string(pdata)) } - deployments, err := c.AppsV1().Deployments(ns).List(ctx, metav1.ListOptions{}) + // CamelCatalogs + cat, err := camelClient.CamelV1().CamelCatalogs(ns).List(ctx, metav1.ListOptions{}) if err != nil { return err } - fmt.Fprintf(out, "Found %d deployments:\n", len(deployments.Items)) - for _, deployment := range deployments.Items { - ref := deployment - data, err := kubernetes.ToYAML(&ref) + fmt.Fprintf(out, "Found %d catalogs:\n", len(pls.Items)) + for _, c := range cat.Items { + ref := c + cdata, err := kubernetes.ToYAML(&ref) if err != nil { return err } - fmt.Fprintf(out, "---\n%s\n---\n", string(data)) + fmt.Fprintf(out, "---\n%s\n---\n", string(cdata)) } + // Pods and Logs lst, err := c.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{}) if err != nil { return err