[go1.15] Use errors.As to unwrap net errors

Kubernetes-commit: c61c60eb1f59c92b0628484b55c640e585555aab
This commit is contained in:
Jordan Liggitt 2020-08-07 15:22:54 -04:00 committed by Kubernetes Publisher
parent 00dbcca6ee
commit e3251a06c1

View File

@ -19,8 +19,6 @@ package memory
import (
"errors"
"fmt"
"net"
"net/url"
"sync"
"syscall"
@ -64,19 +62,11 @@ var _ discovery.CachedDiscoveryInterface = &memCacheClient{}
// "Connection reset" error which usually means that apiserver is temporarily
// unavailable.
func isTransientConnectionError(err error) bool {
urlError, ok := err.(*url.Error)
if !ok {
return false
var errno syscall.Errno
if errors.As(err, &errno) {
return errno == syscall.ECONNREFUSED || errno == syscall.ECONNRESET
}
opError, ok := urlError.Err.(*net.OpError)
if !ok {
return false
}
errno, ok := opError.Err.(syscall.Errno)
if !ok {
return false
}
return errno == syscall.ECONNREFUSED || errno == syscall.ECONNRESET
return false
}
func isTransientError(err error) bool {