From c1c22c383197591f869572faf9c6ee0eecbb1fb3 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Thu, 27 Jan 2022 18:20:41 +0100 Subject: [PATCH] Make kube-controller-manager service return errors Signed-off-by: Miguel Angel Ajo --- pkg/controllers/kube-controller-manager.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/controllers/kube-controller-manager.go b/pkg/controllers/kube-controller-manager.go index 32ecfb783a..bec3099d53 100644 --- a/pkg/controllers/kube-controller-manager.go +++ b/pkg/controllers/kube-controller-manager.go @@ -17,7 +17,7 @@ package controllers import ( "context" - "fmt" + "errors" "path/filepath" "github.com/spf13/cobra" @@ -95,12 +95,14 @@ func (s *KubeControllerManager) configure(cfg *config.MicroshiftConfig) { func (s *KubeControllerManager) Run(ctx context.Context, ready chan<- struct{}, stopped chan<- struct{}) error { defer close(stopped) + errorChannel := make(chan error, 1) // run readiness check go func() { healthcheckStatus := util.RetryInsecureHttpsGet("https://127.0.0.1:10257/healthz") if healthcheckStatus != 200 { - klog.Fatalf("", fmt.Errorf("kube-controller-manager failed to start")) + klog.Errorf("kube-controller-manager failed to start") + errorChannel <- errors.New("kube-controller-manager failed to start") } klog.Infof("%s is ready", s.Name()) @@ -117,10 +119,9 @@ func (s *KubeControllerManager) Run(ctx context.Context, ready chan<- struct{}, // return err //} - // Run runs the KubeControllerManagerOptions. This should never exit. - if err := kubecm.Run(c.Complete(), ctx.Done()); err != nil { - return err - } + go func() { + errorChannel <- kubecm.Run(c.Complete(), ctx.Done()) + }() - return ctx.Err() + return <-errorChannel }