File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -446,13 +446,16 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) {
446
446
447
447
// Start the leader election and all required runnables.
448
448
{
449
- ctx , cancel := context .WithCancel (context .Background ())
449
+ // Create a context that inherits all keys from the parent context
450
+ // but can be cancelled independently for leader election management
451
+ baseCtx := context .WithoutCancel (ctx )
452
+ leaderCtx , cancel := context .WithCancel (baseCtx )
450
453
cm .leaderElectionCancel = cancel
451
454
if leaderElector != nil {
452
455
// Start the leader elector process
453
456
go func () {
454
- leaderElector .Run (ctx )
455
- <- ctx .Done ()
457
+ leaderElector .Run (leaderCtx )
458
+ <- leaderCtx .Done ()
456
459
close (cm .leaderElectionStopped )
457
460
}()
458
461
} else {
You can’t perform that action at this time.
0 commit comments