未验证 提交 f29c0cd3 编写于 作者: T Thomas Strömberg 提交者: GitHub

Merge pull request #3533 from tstromberg/kubeadm-log-output

Improve failure output when kubeadm init fails
......@@ -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 {
......
......@@ -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
}
}
......
......@@ -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")) {
......
......@@ -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
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册