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

Add a machine readable reason to all error paths #9126

Merged
merged 7 commits into from
Sep 1, 2020
Prev Previous commit
Next Next commit
Unwrap unnecessary level of error annotation for improved messages
  • Loading branch information
tstromberg committed Aug 31, 2020
commit cd91fb84702daf538d3d809868a06e3f3bf61df0
14 changes: 11 additions & 3 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func maybeDeleteAndRetry(cmd *cobra.Command, existing config.ClusterConfig, n co
return kubeconfig, nil
}
// Don't delete the cluster unless they ask
return nil, errors.Wrap(originalErr, "startup failed")
return nil, originalErr
}

func kubectlVersion(path string) (string, error) {
Expand Down Expand Up @@ -669,10 +669,18 @@ func validateDriver(ds registry.DriverState, existing *config.ClusterConfig) {
}, `The '{{.driver}}' provider was not found: {{.error}}`, out.V{"driver": name, "error": st.Error})
}

id := fmt.Sprintf("PROVIDER_%s_ERROR", strings.ToUpper(name))
code := reason.ExProviderUnavailable

if !st.Running {
id = fmt.Sprintf("PROVIDER_%s_NOT_RUNNING", strings.ToUpper(name))
code = reason.ExProviderNotRunning
}

exitIfNotForced(reason.Kind{
ID: fmt.Sprintf("PROVIDER_%s_ERROR", strings.ToUpper(name)),
ID: id,
Advice: translate.T(st.Fix),
ExitCode: reason.ExProviderNotFound,
ExitCode: code,
URL: st.Doc,
Style: style.Fatal,
}, st.Error.Error())
Expand Down
5 changes: 1 addition & 4 deletions pkg/minikube/kubeconfig/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ func SetCurrentContext(name string, configPath ...string) error {
return errors.Wrap(err, "Error getting kubeconfig status")
}
kcfg.CurrentContext = name
if err := writeToFile(kcfg, fPath); err != nil {
return errors.Wrap(err, "writing kubeconfig")
}
return nil
return writeToFile(kcfg, fPath)
}

// DeleteContext deletes the specified machine's kubeconfig context
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {

// write the kubeconfig to the file system after everything required (like certs) are created by the bootstrapper
if err := kubeconfig.Update(kcs); err != nil {
return nil, errors.Wrap(err, "Failed to update kubeconfig file.")
return nil, errors.Wrap(err, "Failed kubeconfig update")
}
} else {
bs, err = cluster.Bootstrapper(starter.MachineAPI, viper.GetString(cmdcfg.Bootstrapper), *starter.Cfg, starter.Runner)
Expand Down