From ae63d6495dcaa807a29ef35ab5b3d1a6089ceaae Mon Sep 17 00:00:00 2001 From: Jamo Luhrsen Date: Fri, 25 Sep 2020 13:22:24 -0700 Subject: [PATCH] Collect debugs before framework.Failf having framework.DumpDebugInfo after the FailF was a noop and we are losing those potentially helpful logs when we need them the most (on a failure) Signed-off-by: Jamo Luhrsen --- test/e2e/network/network_policy.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/e2e/network/network_policy.go b/test/e2e/network/network_policy.go index c32fadf82fb..7320cc0b47f 100644 --- a/test/e2e/network/network_policy.go +++ b/test/e2e/network/network_policy.go @@ -2017,11 +2017,12 @@ func checkConnectivity(f *framework.Framework, ns *v1.Namespace, podClient *v1.P framework.Logf("Waiting for %s to complete.", podClient.Name) err = e2epod.WaitForPodSuccessInNamespace(f.ClientSet, podClient.Name, ns.Name) if err != nil { + // Dump debug information for the test namespace. + framework.DumpDebugInfo(f.ClientSet, f.Namespace.Name) + pods, policies, logs := collectPodsAndNetworkPolicies(f, podClient) framework.Failf("Pod %s should be able to connect to service %s, but was not able to connect.\nPod logs:\n%s\n\n Current NetworkPolicies:\n\t%v\n\n Pods:\n\t%v\n\n", podClient.Name, service.Name, logs, policies.Items, pods) - // Dump debug information for the test namespace. - framework.DumpDebugInfo(f.ClientSet, f.Namespace.Name) } } @@ -2032,11 +2033,12 @@ func checkNoConnectivity(f *framework.Framework, ns *v1.Namespace, podClient *v1 // We expect an error here since it's a cannot connect test. // Dump debug information if the error was nil. if err == nil { + // Dump debug information for the test namespace. + framework.DumpDebugInfo(f.ClientSet, f.Namespace.Name) + pods, policies, logs := collectPodsAndNetworkPolicies(f, podClient) framework.Failf("Pod %s should not be able to connect to service %s, but was able to connect.\nPod logs:\n%s\n\n Current NetworkPolicies:\n\t%v\n\n Pods:\n\t %v\n\n", podClient.Name, service.Name, logs, policies.Items, pods) - // Dump debug information for the test namespace. - framework.DumpDebugInfo(f.ClientSet, f.Namespace.Name) } }