Skip to content

Commit 857be80

Browse files
Merge pull request #3576 from demirdilek/fix-leaderelection-contextual-logging
✨ Pass Managers Logger to Leader Elector via Context
2 parents b1387be + db9df3c commit 857be80

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎pkg/manager/internal.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) {
462462
// Create a context that inherits all keys from the parent context
463463
// but can be cancelled independently for leader election management
464464
baseCtx := context.WithoutCancel(ctx)
465+
466+
// Inject the logger into the context for client-go contextual logging
467+
baseCtx = logr.NewContext(baseCtx, cm.logger.WithName("leaderelection"))
468+
465469
leaderCtx, cancel := context.WithCancel(baseCtx)
466470
cm.leaderElectionCancel = cancel
467471
if leaderElector != nil {

0 commit comments

Comments
 (0)