Skip to content

Commit

Permalink
Fix retry on timeouts (#304)
Browse files Browse the repository at this point in the history
Fix retry after Go 1.23 change: golang/go#50856
  • Loading branch information
klauspost authored Sep 5, 2024
1 parent 793e1bf commit 6aad3ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,9 @@ func (adm AdminClient) executeMethod(ctx context.Context, method string, reqData
if errors.Is(err, syscall.ECONNREFUSED) {
return nil, err
}
if err == context.Canceled || err == context.DeadlineExceeded {
return nil, err
// Give up if caller canceled.
if ctx.Err() != nil {
return nil, ctx.Err()
}
// retry all network errors.
continue
Expand Down
2 changes: 1 addition & 1 deletion perf-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (adm *AdminClient) ClientPerf(ctx context.Context, dur time.Duration) (resu
contentReader: reader,
})
reader.End()
if errors.Is(err, context.DeadlineExceeded) {
if errors.Is(err, context.DeadlineExceeded) && ctx.Err() != nil {
err = nil
}

Expand Down

0 comments on commit 6aad3ae

Please sign in to comment.