Skip to content

Commit c07b12a

Browse files
committed
Print k8s pods if a poller times out
Signed-off-by: David Gageot <[email protected]>
1 parent d259c9b commit c07b12a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

integration/util.go

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package integration
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"os/exec"
2223
"testing"
2324
"time"
@@ -95,6 +96,7 @@ func (k *NSKubernetesClient) WaitForPodsReady(podNames ...string) {
9596
waitLoop:
9697
select {
9798
case <-ctx.Done():
99+
k.debug("pods")
98100
k.t.Fatalf("Timed out waiting for pods %v ready in namespace %s", podNames, k.ns)
99101

100102
case event := <-w.ResultChan():
@@ -147,6 +149,8 @@ func (k *NSKubernetesClient) WaitForDeploymentsToStabilize(depNames ...string) {
147149
waitLoop:
148150
select {
149151
case <-ctx.Done():
152+
k.debug("deployments.apps")
153+
k.debug("pods")
150154
k.t.Fatalf("Timed out waiting for deployments %v to stabilize in namespace %s", depNames, k.ns)
151155

152156
case event := <-w.ResultChan():
@@ -167,6 +171,16 @@ func (k *NSKubernetesClient) WaitForDeploymentsToStabilize(depNames ...string) {
167171
}
168172
}
169173

174+
// debug is used to print all the details about pods or deployments
175+
func (k *NSKubernetesClient) debug(entities string) {
176+
cmd := exec.Command("kubectl", "-n", k.ns, "get", entities, "-oyaml")
177+
out, _ := cmd.CombinedOutput()
178+
179+
logrus.Warnln(cmd.Args)
180+
// Use fmt.Println, not logrus, for prettier output
181+
fmt.Println(string(out))
182+
}
183+
170184
func isStable(dp *appsv1.Deployment) bool {
171185
return dp.Generation <= dp.Status.ObservedGeneration && *(dp.Spec.Replicas) == dp.Status.Replicas
172186
}

0 commit comments

Comments
 (0)