From 355a140de965e241ef646e3a0050a00dd915bd45 Mon Sep 17 00:00:00 2001 From: Dan Rammer Date: Fri, 7 Apr 2023 12:22:20 -0500 Subject: [PATCH] moved controller runtime start out of webhook Run function (#546) Signed-off-by: Daniel Rammer --- flytepropeller/cmd/controller/cmd/webhook.go | 8 ++++++++ flytepropeller/pkg/webhook/entrypoint.go | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/flytepropeller/cmd/controller/cmd/webhook.go b/flytepropeller/cmd/controller/cmd/webhook.go index d22da0f283..87e19448df 100644 --- a/flytepropeller/cmd/controller/cmd/webhook.go +++ b/flytepropeller/cmd/controller/cmd/webhook.go @@ -130,6 +130,14 @@ func runWebhook(origContext context.Context, propellerCfg *config.Config, cfg *w return err }) + g.Go(func() error { + err := controller.StartControllerManager(childCtx, mgr) + if err != nil { + logger.Fatalf(childCtx, "Failed to start controller manager. Error: %v", err) + } + return err + }) + g.Go(func() error { err := webhook.Run(childCtx, propellerCfg, cfg, defaultNamespace, &webhookScope, mgr) if err != nil { diff --git a/flytepropeller/pkg/webhook/entrypoint.go b/flytepropeller/pkg/webhook/entrypoint.go index 4f5a068251..50c4099c2e 100644 --- a/flytepropeller/pkg/webhook/entrypoint.go +++ b/flytepropeller/pkg/webhook/entrypoint.go @@ -52,8 +52,10 @@ func Run(ctx context.Context, propellerCfg *config.Config, cfg *config2.Config, logger.Fatalf(ctx, "Failed to register webhook with manager. Error: %v", err) } - logger.Infof(ctx, "Starting controller-runtime manager") - return (*mgr).Start(ctx) + logger.Infof(ctx, "Started propeller webhook") + <-ctx.Done() + + return nil } func createMutationConfig(ctx context.Context, kubeClient *kubernetes.Clientset, webhookObj *PodMutator, defaultNamespace string) error {