Merge pull request #30405 from zmerlynn/dump-on-up-fail

Automatic merge from submit-queue

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.)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.kubernetes.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.kubernetes.io/reviews/kubernetes/kubernetes/30405)
<!-- Reviewable:end -->
pull/6/head
Kubernetes Submit Queue 2016-08-11 23:54:08 -07:00 committed by GitHub
commit ff3bd05efb
1 changed files with 10 additions and 4 deletions

View File

@ -43,7 +43,7 @@ var (
checkLeakedResources = flag.Bool("check_leaked_resources", false, "Ensure project ends with the same resources") 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.") 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.") 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.") 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.") 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.") 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 {
if !Up() { if !Up() {
DumpClusterLogs(*dump)
log.Fatal("Error starting e2e cluster. Aborting.") log.Fatal("Error starting e2e cluster. Aborting.")
} }
} else if *push { } else if *push {
if !finishRunning("push", exec.Command("./hack/e2e-internal/e2e-push.sh")) { if !finishRunning("push", exec.Command("./hack/e2e-internal/e2e-push.sh")) {
DumpClusterLogs(*dump)
log.Fatal("Error pushing e2e cluster. Aborting.") log.Fatal("Error pushing e2e cluster. Aborting.")
} }
} }
@ -170,10 +172,11 @@ func main() {
success = success && kubeSuccess success = success && kubeSuccess
} }
if !success {
DumpClusterLogs(*dump)
}
if *down { if *down {
if !success && *dump != "" {
DumpClusterLogs(*dump)
}
tearSuccess := TearDown() tearSuccess := TearDown()
success = success && tearSuccess success = success && tearSuccess
} }
@ -293,6 +296,9 @@ func IsUp() bool {
} }
func DumpClusterLogs(location string) { func DumpClusterLogs(location string) {
if location == "" {
return
}
log.Printf("Dumping cluster logs to: %v", location) log.Printf("Dumping cluster logs to: %v", location)
finishRunning("dump cluster logs", exec.Command("./cluster/log-dump.sh", location)) finishRunning("dump cluster logs", exec.Command("./cluster/log-dump.sh", location))
} }