Merge pull request #93571 from ChrsMark/patch-1

Document blocking behaviour of RunOrDie and Run
This commit is contained in:
Kubernetes Prow Robot 2020-08-27 00:07:58 -07:00 committed by GitHub
commit 6b963ed9c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -193,7 +193,9 @@ type LeaderElector struct {
name string
}
// Run starts the leader election loop
// Run starts the leader election loop. Run will not return
// before leader election loop is stopped by ctx or it has
// stopped holding the leader lease
func (le *LeaderElector) Run(ctx context.Context) {
defer runtime.HandleCrash()
defer func() {
@ -210,7 +212,8 @@ func (le *LeaderElector) Run(ctx context.Context) {
}
// RunOrDie starts a client with the provided config or panics if the config
// fails to validate.
// fails to validate. RunOrDie blocks until leader election loop is
// stopped by ctx or it has stopped holding the leader lease
func RunOrDie(ctx context.Context, lec LeaderElectionConfig) {
le, err := NewLeaderElector(lec)
if err != nil {