mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	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.)
This commit is contained in:
		
							
								
								
									
										12
									
								
								hack/e2e.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								hack/e2e.go
									
									
									
									
									
								
							@@ -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 *down {
 | 
						if !success {
 | 
				
			||||||
		if !success && *dump != "" {
 | 
					 | 
				
			||||||
		DumpClusterLogs(*dump)
 | 
							DumpClusterLogs(*dump)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if *down {
 | 
				
			||||||
		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))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user