Enable retry EOF from http request

If the *url.Error type error casued by EOF, enable to retry.

Signed-off-by: Qi Wang <qiwan@redhat.com>
This commit is contained in:
Qi Wang 2020-08-20 10:23:09 -04:00
parent 0f5b7db0f3
commit 499c4ef5a7
1 changed files with 5 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package retry
import ( import (
"context" "context"
"io"
"math" "math"
"net" "net"
"net/url" "net/url"
@ -58,7 +59,10 @@ func isRetryable(err error) bool {
return true return true
case *net.OpError: case *net.OpError:
return isRetryable(e.Err) return isRetryable(e.Err)
case *url.Error: case *url.Error: // This includes errors returned by the net/http client.
if e.Err == io.EOF {
return true
}
return isRetryable(e.Err) return isRetryable(e.Err)
case syscall.Errno: case syscall.Errno:
return e != syscall.ECONNREFUSED return e != syscall.ECONNREFUSED