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) {
446446
447447 // Start the leader election and all required runnables.
448448 {
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 )
450453 cm .leaderElectionCancel = cancel
451454 if leaderElector != nil {
452455 // Start the leader elector process
453456 go func () {
454- leaderElector .Run (ctx )
455- <- ctx .Done ()
457+ leaderElector .Run (leaderCtx )
458+ <- leaderCtx .Done ()
456459 close (cm .leaderElectionStopped )
457460 }()
458461 } else {
You can’t perform that action at this time.
0 commit comments