Skip to content

Commit 3f9a825

Browse files
committed
Pass appropriate context to leaderelector.Run
1 parent 4276f38 commit 3f9a825

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
@@ -309,7 +309,16 @@ func (cm *controllerManager) startLeaderElection() (err error) {
309309
return err
310310
}
311311

312+
ctx, cancel := context.WithCancel(context.Background())
313+
go func() {
314+
select {
315+
case <-cm.internalStop:
316+
cancel()
317+
case <-ctx.Done():
318+
}
319+
}()
320+
312321
// Start the leader elector process
313-
go l.Run(context.Background())
322+
go l.Run(ctx)
314323
return nil
315324
}

0 commit comments

Comments
 (0)