From 885f139e0e3658e1ec74caeff8c6d65c34330e6e Mon Sep 17 00:00:00 2001 From: LaurentiuNiculae Date: Thu, 29 Sep 2022 23:28:39 +0300 Subject: [PATCH] Remove forking logger (#825) - no longer needed, the race conditions were fixed Signed-off-by: Laurentiu Niculae --- pkg/extensions/extension_metrics.go | 4 +--- pkg/extensions/extension_search.go | 4 +--- pkg/extensions/sync/sync.go | 5 +---- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/extensions/extension_metrics.go b/pkg/extensions/extension_metrics.go index 24ef0108..9941984d 100644 --- a/pkg/extensions/extension_metrics.go +++ b/pkg/extensions/extension_metrics.go @@ -26,10 +26,8 @@ func EnableMetricsExtension(config *config.Config, log log.Logger, rootDir strin } func SetupMetricsRoutes(config *config.Config, router *mux.Router, storeController storage.StoreController, - l log.Logger, + log log.Logger, ) { - // fork a new zerolog child to avoid data race - log := log.Logger{Logger: l.With().Caller().Timestamp().Logger()} log.Info().Msg("setting up metrics routes") if config.Extensions.Metrics != nil && *config.Extensions.Metrics.Enable { diff --git a/pkg/extensions/extension_search.go b/pkg/extensions/extension_search.go index 906377b9..a11ff3eb 100644 --- a/pkg/extensions/extension_search.go +++ b/pkg/extensions/extension_search.go @@ -62,10 +62,8 @@ func downloadTrivyDB(log log.Logger, updateInterval time.Duration) error { } func SetupSearchRoutes(config *config.Config, router *mux.Router, storeController storage.StoreController, - l log.Logger, + log log.Logger, ) { - // fork a new zerolog child to avoid data race - log := log.Logger{Logger: l.With().Caller().Timestamp().Logger()} log.Info().Msg("setting up search routes") if config.Extensions.Search != nil && *config.Extensions.Search.Enable { diff --git a/pkg/extensions/sync/sync.go b/pkg/extensions/sync/sync.go index 42a7d906..f6e69ce1 100644 --- a/pkg/extensions/sync/sync.go +++ b/pkg/extensions/sync/sync.go @@ -614,9 +614,6 @@ func Run(ctx context.Context, cfg Config, ticker := time.NewTicker(regCfg.PollInterval) - // fork a new zerolog child to avoid data race - tlogger := log.Logger{Logger: logger.Logger} - retryOptions := &retry.RetryOptions{} if regCfg.MaxRetries != nil { @@ -658,7 +655,7 @@ func Run(ctx context.Context, cfg Config, continue } } - }(ctx, regCfg, tlogger) + }(ctx, regCfg, logger) } logger.Info().Msg("finished setting up sync")