mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Fix: return error instead of os.Exit when something goes wrong
This commit is contained in:
parent
e4c795168b
commit
f80ddac1bc
@ -475,33 +475,34 @@ Service cluster IPs and ports are currently found through Docker-links-compatibl
|
||||
environment variables specifying ports opened by the service proxy. There is an optional
|
||||
addon that provides cluster DNS for these cluster IPs. The user must create a service
|
||||
with the apiserver API to configure the proxy.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
verflag.PrintAndExitIfRequested()
|
||||
cliflag.PrintFlags(cmd.Flags())
|
||||
|
||||
if err := initForOS(opts.WindowsService); err != nil {
|
||||
klog.ErrorS(err, "Failed OS init")
|
||||
// ACTION REQUIRED: Exit code changed from 255 to 1
|
||||
os.Exit(1)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := opts.Complete(); err != nil {
|
||||
klog.ErrorS(err, "Failed complete")
|
||||
// ACTION REQUIRED: Exit code changed from 255 to 1
|
||||
os.Exit(1)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := opts.Validate(); err != nil {
|
||||
klog.ErrorS(err, "Failed validate")
|
||||
// ACTION REQUIRED: Exit code changed from 255 to 1
|
||||
os.Exit(1)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := opts.Run(); err != nil {
|
||||
klog.ErrorS(err, "Error running ProxyServer")
|
||||
os.Exit(1)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
SilenceUsage: true,
|
||||
SilenceErrors: true,
|
||||
Args: func(cmd *cobra.Command, args []string) error {
|
||||
for _, arg := range args {
|
||||
if len(arg) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user