Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve failure output when kubeadm init fails #3533

Merged
merged 5 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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