Skip to content

Commit 9b7af76

Browse files
committed
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 <akpant@redhat.com>
1 parent e88c518 commit 9b7af76

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

pkg/adapter/v2/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package adapter
1818

1919
import (
2020
"context"
21+
"errors"
2122
"flag"
2223
"fmt"
2324
"log"
@@ -284,6 +285,18 @@ func MainWithInformers(ctx context.Context, component string, env EnvConfigAcces
284285
}()
285286
}
286287

288+
wg.Add(1)
289+
go func() {
290+
defer wg.Done()
291+
go func() {
292+
<-ctx.Done()
293+
_ = pprof.Shutdown(context.Background())
294+
}()
295+
if err := pprof.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
296+
logger.Warnw("Profiling server shut down", zap.Error(err))
297+
}
298+
}()
299+
287300
// Finally start the adapter (blocking)
288301
if err := adapter.Start(ctx); err != nil {
289302
logger.Fatalw("Start returned an error", zap.Error(err))

0 commit comments

Comments
 (0)