From 7be964a6f97d40c37e704c0ff41e9dfcb8f24251 Mon Sep 17 00:00:00 2001 From: SarthakB11 Date: Thu, 30 Apr 2026 23:33:26 +0000 Subject: [PATCH] fix(app): wire signal-aware context through controller startup the controller's Start function used context.Background() for tracing init, migrations, and db connect, while ctrl.SetupSignalHandler() was only invoked later for mgr.Start. on sigterm during startup, those early operations ignored the cancellation and could hang past the pod's terminationGracePeriod. call ctrl.SetupSignalHandler() once at the top of Start, reuse the returned context for both startup work and mgr.Start. controller-runtime's signal handler must be called exactly once per process; collapsing the two call sites also removes a latent panic risk if a future caller added another signal-handler setup. resolves the long-standing 'TODO setup signal handlers' in app.go. Signed-off-by: SarthakB11 --- go/core/pkg/app/app.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/core/pkg/app/app.go b/go/core/pkg/app/app.go index eabd6ff05..f5bb09a64 100644 --- a/go/core/pkg/app/app.go +++ b/go/core/pkg/app/app.go @@ -294,8 +294,8 @@ func Start(getExtensionConfig GetExtensionConfig, migrationRunner MigrationRunne var tlsOpts []func(*tls.Config) var cfg Config - // TODO setup signal handlers - ctx := context.Background() + // Reused below for mgr.Start; SetupSignalHandler must be called once per process. + ctx := ctrl.SetupSignalHandler() cfg.SetFlags(flag.CommandLine) @@ -667,7 +667,7 @@ func Start(getExtensionConfig GetExtensionConfig, migrationRunner MigrationRunne } setupLog.Info("starting manager") - if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { + if err := mgr.Start(ctx); err != nil { setupLog.Error(err, "problem running manager") os.Exit(1) }