Skip to content

Commit

Permalink
Output pod+deployment logs
Browse files Browse the repository at this point in the history
  • Loading branch information
briandealwis committed Jan 20, 2021
1 parent 475a15a commit a76ca45
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions integration/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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() {
Expand All @@ -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{})
Expand Down

0 comments on commit a76ca45

Please sign in to comment.