Smoothly retry host startup
parent
c50cfc99fa
commit
82eafa57d4
|
@ -320,14 +320,45 @@ func startMachine(cfg *config.ClusterConfig, node *config.Node) (runner command.
|
||||||
}
|
}
|
||||||
|
|
||||||
// startHost starts a new minikube host using a VM or None
|
// startHost starts a new minikube host using a VM or None
|
||||||
func startHost(api libmachine.API, mc config.ClusterConfig, n config.Node) (*host.Host, bool) {
|
func startHost(api libmachine.API, cc config.ClusterConfig, n config.Node) (*host.Host, bool) {
|
||||||
host, exists, err := machine.StartHost(api, mc, n)
|
host, exists, err := machine.StartHost(api, cc, n)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
exit.WithError("Unable to start VM. Please investigate and run 'minikube delete' if possible", err)
|
return host, exists
|
||||||
}
|
}
|
||||||
|
out.T(out.Embarrassed, "StartHost failed, but will try again: {{.error}}", out.V{"error": err})
|
||||||
|
|
||||||
|
// NOTE: People get very cranky if you delete their prexisting VM. Only delete new ones.
|
||||||
|
if !exists {
|
||||||
|
err := machine.DeleteHost(api, driver.MachineName(cc, n))
|
||||||
|
if err != nil {
|
||||||
|
glog.Warningf("delete host: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try again, but just once to avoid copious error messages
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
|
||||||
|
host, exists, err = machine.StartHost(api, cc, n)
|
||||||
|
if err == nil {
|
||||||
|
return host, exists
|
||||||
|
}
|
||||||
|
|
||||||
|
out.T(out.FailureType, "StartHost failed again: {{.error}}", out.V{"error": err})
|
||||||
|
out.T(out.Workaround, `Run: "{{.cmd}} delete", then "{{.cmd}} start --alsologtostderr -v=1" to try again with more logs`,
|
||||||
|
out.V{"cmd": minikubeCmd()})
|
||||||
|
|
||||||
|
exit.WithError("Unable to start VM after repeated tries. Please try {{'minikube delete' if possible", err)
|
||||||
return host, exists
|
return host, exists
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return a minikube command containing the current profile name
|
||||||
|
func minikubeCmd() string {
|
||||||
|
if viper.GetString(config.ProfileName) != constants.DefaultClusterName {
|
||||||
|
return fmt.Sprintf("minikube -p %s", config.ProfileName)
|
||||||
|
}
|
||||||
|
return "minikube"
|
||||||
|
}
|
||||||
|
|
||||||
// validateNetwork tries to catch network problems as soon as possible
|
// validateNetwork tries to catch network problems as soon as possible
|
||||||
func validateNetwork(h *host.Host, r command.Runner) string {
|
func validateNetwork(h *host.Host, r command.Runner) string {
|
||||||
ip, err := h.Driver.GetIP()
|
ip, err := h.Driver.GetIP()
|
||||||
|
|
Loading…
Reference in New Issue