diff --git a/integration/util.go b/integration/util.go index cd109b05e42..ca5869b94dd 100644 --- a/integration/util.go +++ b/integration/util.go @@ -199,6 +199,7 @@ func (k *NSKubernetesClient) WaitForPodsInPhase(expectedPhase v1.PodPhase, podNa k.printDiskFreeSpace() //k.debug("nodes") k.debug("pods") + k.logs("pod", podNames) k.t.Fatalf("Timed out waiting for pods %v ready in namespace %s", podNames, k.ns) case event := <-w.ResultChan(): @@ -285,6 +286,7 @@ func (k *NSKubernetesClient) waitForDeploymentsToStabilizeWithTimeout(timeout ti //k.debug("nodes") k.debug("deployments.apps") k.debug("pods") + k.logs("deployment.app", depNames) k.t.Fatalf("Timed out waiting for deployments %v to stabilize in namespace %s", depNames, k.ns) case event := <-w.ResultChan(): @@ -315,9 +317,7 @@ func (k *NSKubernetesClient) debug(entities string) { cmd := exec.Command("kubectl", "-n", k.ns, "get", entities, "-oyaml") logrus.Warnln(cmd.Args) out, _ := cmd.CombinedOutput() - - // Use fmt.Println, not logrus, for prettier output - fmt.Println(string(out)) + fmt.Println(string(out)) // Use fmt.Println, not logrus, for prettier output } func (k *NSKubernetesClient) printDiskFreeSpace() { @@ -327,6 +327,16 @@ func (k *NSKubernetesClient) printDiskFreeSpace() { fmt.Println(string(out)) } +// logs is used to print the logs of a resource +func (k *NSKubernetesClient) logs(entity string, names []string) { + for _, n := range names { + cmd := exec.Command("kubectl", "-n", k.ns, "logs", entity+"/"+n) + logrus.Warnln(cmd.Args) + out, _ := cmd.CombinedOutput() + fmt.Println(string(out)) // Use fmt.Println, not logrus, for prettier output + } +} + // ExternalIP waits for the external IP aof a given service. func (k *NSKubernetesClient) ExternalIP(serviceName string) string { svc, err := k.Services().Get(context.Background(), serviceName, metav1.GetOptions{})