From c49e0343e33f98ff1bf699aed92711b083e4291e Mon Sep 17 00:00:00 2001 From: Yuan Tang Date: Tue, 21 Jun 2022 16:16:41 -0400 Subject: [PATCH] feat: Treat connection reset as a retryable error Signed-off-by: Yuan Tang --- controller/cache/cache.go | 3 ++- controller/cache/cache_test.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/controller/cache/cache.go b/controller/cache/cache.go index 4149cc09c1a62..4cae8a3614ace 100644 --- a/controller/cache/cache.go +++ b/controller/cache/cache.go @@ -354,7 +354,8 @@ func isTransientNetworkErr(err error) bool { } if strings.Contains(errorString, "net/http: TLS handshake timeout") || strings.Contains(errorString, "i/o timeout") || - strings.Contains(errorString, "connection timed out") { + strings.Contains(errorString, "connection timed out") || + strings.Contains(errorString, "connection reset by peer") { return true } return false diff --git a/controller/cache/cache_test.go b/controller/cache/cache_test.go index aa6f26540b618..dcff97edb2157 100644 --- a/controller/cache/cache_test.go +++ b/controller/cache/cache_test.go @@ -111,6 +111,7 @@ func TestIsRetryableError(t *testing.T) { tlsHandshakeTimeoutErr net.Error = netError("net/http: TLS handshake timeout") ioTimeoutErr net.Error = netError("i/o timeout") connectionTimedout net.Error = netError("connection timed out") + connectionReset net.Error = netError("connection reset by peer") ) t.Run("Nil", func(t *testing.T) { assert.False(t, isRetryableError(nil)) @@ -148,4 +149,7 @@ func TestIsRetryableError(t *testing.T) { t.Run("ConnectionTimeout", func(t *testing.T) { assert.True(t, isRetryableError(connectionTimedout)) }) + t.Run("ConnectionReset", func(t *testing.T) { + assert.True(t, isRetryableError(connectionReset)) + }) }