diff --git a/internal/leadership/elector.go b/internal/leadership/elector.go index 69ddd75c..7cac3243 100644 --- a/internal/leadership/elector.go +++ b/internal/leadership/elector.go @@ -136,8 +136,10 @@ func (e *Elector) Start(ctx context.Context) error { return nil } - // We'll send to this channel anytime a leader resigns on the key with `name` - e.leaderResignedChan = make(chan struct{}) + // We'll send to this channel anytime a leader resigns on the key with `name`. + // Buffered to 1 so a send doesn't block if the receiving loop hasn't entered + // its select yet (e.g. between gaining and maintaining leadership). + e.leaderResignedChan = make(chan struct{}, 1) e.requestResignChan = make(chan struct{})