diff --git a/pkg/minikube/exit/exit.go b/pkg/minikube/exit/exit.go index 4ed989d2a6..221001f86e 100644 --- a/pkg/minikube/exit/exit.go +++ b/pkg/minikube/exit/exit.go @@ -61,16 +61,16 @@ func WithCodeT(code int, format string, a ...out.V) { func WithError(msg string, err error) { p := problem.FromError(err, runtime.GOOS) if p != nil { - WithProblem(msg, p) + WithProblem(msg, err, p) } displayError(msg, err) os.Exit(Software) } // WithProblem outputs info related to a known problem and exits. -func WithProblem(msg string, p *problem.Problem) { +func WithProblem(msg string, err error, p *problem.Problem) { out.ErrT(out.Empty, "") - out.FatalT(msg) + out.ErrT(out.FailureType, "[{{.id}}] {{.msg}} {{.error}}", out.V{"msg": msg, "id": p.ID, "error": p.Err}) p.Display() if p.ShowIssueLink { out.ErrT(out.Empty, "") diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 6fdb78e63c..e0ebeaef83 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -351,10 +351,7 @@ func startHost(api libmachine.API, cc config.ClusterConfig, n config.Node) (*hos return host, exists } - out.T(out.FailureType, "StartHost failed again: {{.error}}", out.V{"error": err}) - out.T(out.Workaround, `Run: "{{.delete}}", then "{{.start}} --alsologtostderr -v=1" to try again with more logging`, - out.V{"delete": mustload.ExampleCmd(cc.Name, "delete"), "start": mustload.ExampleCmd(cc.Name, "start")}) - + // Don't use host.Driver to avoid nil pointer deref drv := cc.Driver exit.WithError(fmt.Sprintf(`Failed to start %s %s. "%s" may fix it.`, drv, driver.MachineType(drv), mustload.ExampleCmd(cc.Name, "start")), err) return host, exists diff --git a/pkg/minikube/problem/problem.go b/pkg/minikube/problem/problem.go index 1de611b0a7..d5465a1830 100644 --- a/pkg/minikube/problem/problem.go +++ b/pkg/minikube/problem/problem.go @@ -57,7 +57,6 @@ type match struct { // Display problem metadata to the console func (p *Problem) Display() { - out.ErrT(out.FailureType, "Error: [{{.id}}] {{.error}}", out.V{"id": p.ID, "error": p.Err}) out.ErrT(out.Tip, "Suggestion: {{.advice}}", out.V{"advice": translate.T(p.Advice)}) if p.URL != "" { out.ErrT(out.Documentation, "Documentation: {{.url}}", out.V{"url": p.URL}) @@ -65,6 +64,12 @@ func (p *Problem) Display() { if len(p.Issues) == 0 { return } + + if len(p.Issues) == 1 { + out.ErrT(out.Issues, "Related issue: {{.url}}", out.V{"url": fmt.Sprintf("%s/%d", issueBase, p.Issues[0])}) + return + } + out.ErrT(out.Issues, "Related issues:") issues := p.Issues if len(issues) > 3 { diff --git a/pkg/minikube/problem/problem_test.go b/pkg/minikube/problem/problem_test.go index 8f37424de3..d954271801 100644 --- a/pkg/minikube/problem/problem_test.go +++ b/pkg/minikube/problem/problem_test.go @@ -44,7 +44,6 @@ func TestDisplay(t *testing.T) { problem: Problem{ID: "example", URL: "example.com", Err: fmt.Errorf("test")}, description: "url, id and err", expected: ` -* Error: [example] test * Suggestion: * Documentation: example.com `, @@ -53,7 +52,6 @@ func TestDisplay(t *testing.T) { problem: Problem{ID: "example", URL: "example.com", Err: fmt.Errorf("test"), Issues: []int{0, 1}, Advice: "you need a hug"}, description: "with 2 issues and suggestion", expected: ` -* Error: [example] test * Suggestion: you need a hug * Documentation: example.com * Related issues: @@ -65,7 +63,6 @@ func TestDisplay(t *testing.T) { problem: Problem{ID: "example", URL: "example.com", Err: fmt.Errorf("test"), Issues: []int{0, 1}}, description: "with 2 issues", expected: ` -* Error: [example] test * Suggestion: * Documentation: example.com * Related issues: @@ -78,7 +75,6 @@ func TestDisplay(t *testing.T) { problem: Problem{ID: "example", URL: "example.com", Err: fmt.Errorf("test"), Issues: []int{0, 1, 2, 3, 4, 5}}, description: "with 6 issues", expected: ` -* Error: [example] test * Suggestion: * Documentation: example.com * Related issues: