From 252ef1989fb4149cf0866ce31580e2a059bf963b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Reme=C5=A1?= Date: Wed, 21 Jul 2021 09:15:31 +0200 Subject: [PATCH] Bug 1984047: Do not use klog.Fatal --- pkg/cmd/start/start.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/cmd/start/start.go b/pkg/cmd/start/start.go index 929367192..5d7bbf97b 100644 --- a/pkg/cmd/start/start.go +++ b/pkg/cmd/start/start.go @@ -69,15 +69,15 @@ func NewGather() *cobra.Command { func runGather(operator *controller.GatherJob, cfg *controllercmd.ControllerCommandConfig) func(cmd *cobra.Command, args []string) { return func(cmd *cobra.Command, args []string) { if configArg := cmd.Flags().Lookup("config").Value.String(); len(configArg) == 0 { - klog.Fatalf("error: --config is required") + klog.Error("error: --config is required") } unstructured, _, _, err := cfg.Config() if err != nil { - klog.Fatal(err) + klog.Error(err) } cont, err := config.LoadConfig(operator.Controller, unstructured.Object, config.ToDisconnectedController) if err != nil { - klog.Fatal(err) + klog.Error(err) } operator.Controller = cont @@ -85,20 +85,20 @@ func runGather(operator *controller.GatherJob, cfg *controllercmd.ControllerComm if kubeConfigPath := cmd.Flags().Lookup("kubeconfig").Value.String(); len(kubeConfigPath) > 0 { kubeConfigBytes, err := ioutil.ReadFile(kubeConfigPath) //nolint: govet if err != nil { - klog.Fatal(err) + klog.Error(err) } kubeConfig, err := clientcmd.NewClientConfigFromBytes(kubeConfigBytes) if err != nil { - klog.Fatal(err) + klog.Error(err) } clientConfig, err = kubeConfig.ClientConfig() if err != nil { - klog.Fatal(err) + klog.Error(err) } } else { clientConfig, err = rest.InClusterConfig() if err != nil { - klog.Fatal(err) + klog.Error(err) } } protoConfig := rest.CopyConfig(clientConfig) @@ -108,7 +108,7 @@ func runGather(operator *controller.GatherJob, cfg *controllercmd.ControllerComm ctx, cancel := context.WithTimeout(context.Background(), operator.Interval) err = operator.Gather(ctx, clientConfig, protoConfig) if err != nil { - klog.Fatal(err) + klog.Error(err) } cancel() os.Exit(0) @@ -125,17 +125,17 @@ func runOperator(operator *controller.Operator, cfg *controllercmd.ControllerCom serviceability.StartProfiler() if configArg := cmd.Flags().Lookup("config").Value.String(); len(configArg) == 0 { - klog.Fatalf("error: --config is required") + klog.Error("error: --config is required") } unstructured, operatorConfig, configBytes, err := cfg.Config() if err != nil { - klog.Fatal(err) + klog.Error(err) } startingFileContent, observedFiles, err := cfg.AddDefaultRotationToConfig(operatorConfig, configBytes) if err != nil { - klog.Fatal(err) + klog.Error(err) } // if the service CA is rotated, we want to restart @@ -164,7 +164,7 @@ func runOperator(operator *controller.Operator, cfg *controllercmd.ControllerCom WithServer(operatorConfig.ServingInfo, operatorConfig.Authentication, operatorConfig.Authorization). WithRestartOnChange(exitOnChangeReactorCh, startingFileContent, observedFiles...) if err := builder.Run(ctx2, unstructured); err != nil { - klog.Fatal(err) + klog.Error(err) } } }