From a3bbe6facc29db4695f3f863541b3cf217001616 Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Tue, 18 Feb 2020 13:28:09 -0800 Subject: [PATCH 1/3] make connection reset error pred more generic, debug logs --- .../terraform/utils/error_retry_predicates.go | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/third_party/terraform/utils/error_retry_predicates.go b/third_party/terraform/utils/error_retry_predicates.go index ba20ec23dfe5..c12bcff42aaf 100644 --- a/third_party/terraform/utils/error_retry_predicates.go +++ b/third_party/terraform/utils/error_retry_predicates.go @@ -67,18 +67,24 @@ func isIoEOFError(err error) (bool, string) { return false, "" } -const connectionResetByPeerErr = "connection reset by peer" - +const connectionResetByPeerErr = ": connection reset by peer" 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, "" } From 722103b2e1de65619f3a7295d23a2b34277670e9 Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Tue, 18 Feb 2020 14:14:47 -0800 Subject: [PATCH 2/3] fmt --- third_party/terraform/utils/error_retry_predicates.go | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/terraform/utils/error_retry_predicates.go b/third_party/terraform/utils/error_retry_predicates.go index c12bcff42aaf..c0211e6d4b18 100644 --- a/third_party/terraform/utils/error_retry_predicates.go +++ b/third_party/terraform/utils/error_retry_predicates.go @@ -68,6 +68,7 @@ func isIoEOFError(err error) (bool, string) { } const connectionResetByPeerErr = ": connection reset by peer" + func isConnectionResetNetworkError(err error) (bool, string) { if strings.HasSuffix(err.Error(), connectionResetByPeerErr) { //TODO(emilymye, TPG#3957): Remove these debug logs From 2c77c651858399d8864c46ea93056a8546fe7e95 Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Tue, 18 Feb 2020 15:31:38 -0800 Subject: [PATCH 3/3] import --- third_party/terraform/utils/error_retry_predicates.go | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/terraform/utils/error_retry_predicates.go b/third_party/terraform/utils/error_retry_predicates.go index c0211e6d4b18..77cd3160810b 100644 --- a/third_party/terraform/utils/error_retry_predicates.go +++ b/third_party/terraform/utils/error_retry_predicates.go @@ -8,6 +8,7 @@ import ( "net/url" "strings" + "golang.org/x/oauth2" "google.golang.org/api/googleapi" )