Skip to content

Commit

Permalink
Merge pull request #1213 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1191-to-release-4.14

[release-4.14] OCPBUGS-30067: fix panic in health check timeouts
  • Loading branch information
openshift-merge-bot[bot] committed Mar 5, 2024
2 parents 2bb59cd + c66fa25 commit c40d710
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/etcdcli/health.go
Expand Up @@ -52,10 +52,13 @@ func getMemberHealth(ctx context.Context, etcdMembers []*etcdserverpb.Member) me
const defaultTimeout = 30 * time.Second
resChan := make(chan healthCheck, 1)
go func() {
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
ctxTimeout, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()

resChan <- checkSingleMemberHealth(ctx, member)
resChan <- checkSingleMemberHealth(ctxTimeout, member)
// closing here to avoid late replies to panic on resChan,
// the result will be considered a timeout anyway
close(resChan)
}()

select {
Expand All @@ -68,8 +71,6 @@ func getMemberHealth(ctx context.Context, etcdMembers []*etcdserverpb.Member) me
Error: fmt.Errorf("30s timeout waiting for member %s to respond to health check",
member.Name)})
}

close(resChan)
}

// Purge any unknown members from the raft term metrics collector.
Expand Down

0 comments on commit c40d710

Please sign in to comment.