shutdown must be called explicitly since pprof listen is part of the errgroup (#3203)

This commit is contained in:
Dave Protasowski 2025-07-02 14:04:55 -04:00 committed by GitHub
parent 13b2dc9d2f
commit 68cdb02d48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -259,7 +259,6 @@ func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, cto
rest.SetDefaultWarningHandler(&logging.WarningHandler{Logger: logger})
pprof := newProfilingServer(logger.Named("pprof"))
defer pprof.Shutdown(context.Background())
CheckK8sClientMinimumVersionOrDie(ctx, logger)
cmw := SetupConfigMapWatchOrDie(ctx, logger)
@ -340,6 +339,8 @@ func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, cto
// returns an error.
<-egCtx.Done()
pprof.Shutdown(context.Background())
// Don't forward ErrServerClosed as that indicates we're already shutting down.
if err := eg.Wait(); err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Errorw("Error while running server", zap.Error(err))