Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(provider): add retry for connection reset by peer error #6108

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions huaweicloud/config/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,23 @@ func (lrt *LogRoundTripper) RoundTrip(request *http.Request) (*http.Response, er
retry++
}

// retry connection reset by peer error
retry = 1
for err != nil && strings.Contains(err.Error(), "connection reset by peer") {
if retry > lrt.MaxRetries {
log.Printf("[DEBUG] [%s] connection error, retries exhausted. Aborting", logId)
err = fmt.Errorf("connection error, retries exhausted. Aborting. Last error was: %s", err)
return nil, err
}

log.Printf("[DEBUG] [%s] connection error, retry number %d: %s", logId, retry, err)

// lintignore:R018
time.Sleep(retryTimeout(retry))
response, err = lrt.Rt.RoundTrip(request)
retry++
}

return response, err
}

Expand Down
Loading