diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 1280bb5a4aa4..bb2e93458b64 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -340,7 +340,7 @@ func runStart(cmd *cobra.Command, args []string) { if !exists || config.VMDriver == constants.DriverNone { fmt.Println("Starting cluster components...") if err := k8sBootstrapper.StartCluster(kubernetesConfig); err != nil { - glog.Errorln("Error starting cluster: ", err) + glog.Errorf("Error starting cluster: %v", err) cmdutil.MaybeReportErrorAndExit(err) } } else { diff --git a/cmd/util/util.go b/cmd/util/util.go index 54604ee1aa0d..123d55661cc8 100644 --- a/cmd/util/util.go +++ b/cmd/util/util.go @@ -130,6 +130,7 @@ func MaybeReportErrorAndExit(errToReport error) { MaybeReportErrorAndExitWithCode(errToReport, 1) } +// MaybeReportErrorAndExitWithCode prompts the user if they would like to report a stack trace, and exits. func MaybeReportErrorAndExitWithCode(errToReport error, returnCode int) { var err error if viper.GetBool(config.WantReportError) { @@ -139,17 +140,24 @@ func MaybeReportErrorAndExitWithCode(errToReport error, returnCode int) { `================================================================================ An error has occurred. Would you like to opt in to sending anonymized crash information to minikube to help prevent future errors? -To opt out of these messages, run the command: - minikube config set WantReportErrorPrompt false + +To disable this prompt, run: 'minikube config set WantReportErrorPrompt false' ================================================================================`) if PromptUserForAccept(os.Stdin) { - minikubeConfig.Set(config.WantReportError, "true") - err = ReportError(errToReport, constants.ReportingURL) + err = minikubeConfig.Set(config.WantReportError, "true") + if err == nil { + err = ReportError(errToReport, constants.ReportingURL) + } + } else { + fmt.Println("Bummer, perhaps next time!") } } + + // This happens when the error was created without errors.Wrap(), and thus has no trace data. if err != nil { - glog.Errorf(err.Error()) + glog.Infof("report error failed: %v", err) } + fmt.Printf("\n\nminikube failed :( exiting with error code %d\n", returnCode) os.Exit(returnCode) } @@ -181,6 +189,7 @@ func PromptUserForAccept(r io.Reader) bool { return false } case <-time.After(30 * time.Second): + fmt.Println("Prompt timed out.") return false } } diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index 0093414c13f8..a62a63da0715 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -170,7 +170,7 @@ func (k *KubeadmBootstrapper) StartCluster(k8s config.KubernetesConfig) error { out, err := k.c.CombinedOutput(b.String()) if err != nil { - return errors.Wrapf(err, "kubeadm init error %s running command: %s", b.String(), out) + return errors.Wrapf(err, "kubeadm init: %s\n%s\n", b.String(), out) } if version.LT(semver.MustParse("1.10.0-alpha.0")) { diff --git a/pkg/minikube/bootstrapper/ssh_runner.go b/pkg/minikube/bootstrapper/ssh_runner.go index f10cb4dab5c0..255a0f31aea1 100644 --- a/pkg/minikube/bootstrapper/ssh_runner.go +++ b/pkg/minikube/bootstrapper/ssh_runner.go @@ -145,7 +145,7 @@ func (s *SSHRunner) CombinedOutput(cmd string) (string, error) { err = teeSSH(sess, cmd, &combined, &combined) out := combined.b.String() if err != nil { - return "", err + return out, err } return out, nil }