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

Make connection reset error pred more generic, debug logs #3143

Merged
merged 3 commits into from
Feb 18, 2020
Merged
Changes from 1 commit
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
26 changes: 16 additions & 10 deletions third_party/terraform/utils/error_retry_predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,24 @@ func isIoEOFError(err error) (bool, string) {
return false, ""
}

const connectionResetByPeerErr = "connection reset by peer"

const connectionResetByPeerErr = ": connection reset by peer"
Copy link
Contributor Author

@emilymye emilymye Feb 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underlying network error is always specifically something like $opType $ip -> $ip: $optype: $error so I think it's ok to try using this error with the colon

func isConnectionResetNetworkError(err error) (bool, string) {
neterr, ok := err.(*net.OpError)
if !ok {
if urlerr, urlok := err.(*url.Error); urlok {
wrappedErr := urlerr.Unwrap()
neterr, ok = wrappedErr.(*net.OpError)
if strings.HasSuffix(err.Error(), connectionResetByPeerErr) {
//TODO(emilymye, TPG#3957): Remove these debug logs
log.Printf("[DEBUG] Found connection reset by peer error of type %T", err)
switch err.(type) {
case *url.Error:
case *net.OpError:
log.Printf("[DEBUG] Connection reset error returned from net/url")
case *googleapi.Error:
log.Printf("[DEBUG] Connection reset error wrapped by googleapi.Error")
case *oauth2.RetrieveError:
log.Printf("[DEBUG] Connection reset error wrapped by oauth2")
default:
log.Printf("[DEBUG] Connection reset error wrapped by %T", err)
}
}
if ok && neterr.Err.Error() == connectionResetByPeerErr {
return true, fmt.Sprintf("Connection reset by peer")

return true, fmt.Sprintf("reset connection")
}
return false, ""
}
Expand Down