Skip to content

Commit

Permalink
Merge pull request #3533 from tstromberg/kubeadm-log-output
Browse files Browse the repository at this point in the history
Improve failure output when kubeadm init fails
  • Loading branch information
tstromberg authored Jan 17, 2019
2 parents e1804d2 + c2bf394 commit f29c0cd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,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 {
Expand Down
19 changes: 14 additions & 5 deletions cmd/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}

Expand Down Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/bootstrapper/ssh_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit f29c0cd

Please sign in to comment.