From f81324bb1b7f6504419d912fd26e0c36b202b70e Mon Sep 17 00:00:00 2001 From: Akshay Pant Date: Wed, 1 Apr 2026 20:14:38 +0530 Subject: [PATCH] fix(adapter): start pprof server when profiling is enabled The eventing adapter framework creates and configures a ProfilingServer but never calls ListenAndServe, so the profiling port is never bound even when runtime-profiling is set to enabled in the observability ConfigMap. Start the server conditionally based on the initial config, consistent with the adapter's static observability config model. Fixes #9007 Signed-off-by: Akshay Pant --- pkg/adapter/v2/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/adapter/v2/main.go b/pkg/adapter/v2/main.go index 0c0ceee85ea..abaf58a8f77 100644 --- a/pkg/adapter/v2/main.go +++ b/pkg/adapter/v2/main.go @@ -18,6 +18,7 @@ package adapter import ( "context" + "errors" "flag" "fmt" "log" @@ -284,11 +285,20 @@ func MainWithInformers(ctx context.Context, component string, env EnvConfigAcces }() } + wg.Add(1) + go func() { + defer wg.Done() + if err := pprof.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { + logger.Warnw("Profiling server shut down", zap.Error(err)) + } + }() + // Finally start the adapter (blocking) if err := adapter.Start(ctx); err != nil { logger.Fatalw("Start returned an error", zap.Error(err)) } + _ = pprof.Shutdown(context.Background()) wg.Wait() }