Skip to content

Commit 056a18a

Browse files
authored
Merge pull request #398 from mrkm4ntr/leaderelector-context
🐛Pass appropriate context to leaderelector.Run
2 parents d708e3d + 3f9a825 commit 056a18a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/manager/internal.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,16 @@ func (cm *controllerManager) startLeaderElection() (err error) {
361361
return err
362362
}
363363

364+
ctx, cancel := context.WithCancel(context.Background())
365+
go func() {
366+
select {
367+
case <-cm.internalStop:
368+
cancel()
369+
case <-ctx.Done():
370+
}
371+
}()
372+
364373
// Start the leader elector process
365-
go l.Run(context.Background())
374+
go l.Run(ctx)
366375
return nil
367376
}

0 commit comments

Comments
 (0)