From 9c70b01b2ae15f1796d79b3b0588227204f6f7bd Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Wed, 10 Aug 2016 15:09:57 -0700 Subject: [PATCH] hack/e2e.go: Make --dump run if --up fails, and if --down isn't specified See https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/logs/kubernetes-e2e-aws/629 for why this would be useful. (And the requirement for --down is just unnecessary AFAICT.) --- hack/e2e.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hack/e2e.go b/hack/e2e.go index 4452a75b4ce..2e00c14fa9a 100644 --- a/hack/e2e.go +++ b/hack/e2e.go @@ -43,7 +43,7 @@ var ( checkLeakedResources = flag.Bool("check_leaked_resources", false, "Ensure project ends with the same resources") ctlCmd = flag.String("ctl", "", "If nonempty, pass this as an argument, and call kubectl. Implies -v.") down = flag.Bool("down", false, "If true, tear down the cluster before exiting.") - dump = flag.String("dump", "", "If set, dump cluster logs to this location") + dump = flag.String("dump", "", "If set, dump cluster logs to this location on test or cluster-up failure") kubemark = flag.Bool("kubemark", false, "If true, run kubemark tests.") isup = flag.Bool("isup", false, "Check to see if the e2e cluster is up, then exit.") push = flag.Bool("push", false, "If true, push to e2e cluster. Has no effect if -up is true.") @@ -127,10 +127,12 @@ func main() { } if *up { if !Up() { + DumpClusterLogs(*dump) log.Fatal("Error starting e2e cluster. Aborting.") } } else if *push { if !finishRunning("push", exec.Command("./hack/e2e-internal/e2e-push.sh")) { + DumpClusterLogs(*dump) log.Fatal("Error pushing e2e cluster. Aborting.") } } @@ -170,10 +172,11 @@ func main() { success = success && kubeSuccess } + if !success { + DumpClusterLogs(*dump) + } + if *down { - if !success && *dump != "" { - DumpClusterLogs(*dump) - } tearSuccess := TearDown() success = success && tearSuccess } @@ -293,6 +296,9 @@ func IsUp() bool { } func DumpClusterLogs(location string) { + if location == "" { + return + } log.Printf("Dumping cluster logs to: %v", location) finishRunning("dump cluster logs", exec.Command("./cluster/log-dump.sh", location)) }