mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-17 00:31:27 +00:00
[go1.15] Use errors.As to unwrap net errors
Kubernetes-commit: c61c60eb1f59c92b0628484b55c640e585555aab
This commit is contained in:
parent
00dbcca6ee
commit
e3251a06c1
@ -19,8 +19,6 @@ package memory
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
|
||||||
"net/url"
|
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@ -64,19 +62,11 @@ var _ discovery.CachedDiscoveryInterface = &memCacheClient{}
|
|||||||
// "Connection reset" error which usually means that apiserver is temporarily
|
// "Connection reset" error which usually means that apiserver is temporarily
|
||||||
// unavailable.
|
// unavailable.
|
||||||
func isTransientConnectionError(err error) bool {
|
func isTransientConnectionError(err error) bool {
|
||||||
urlError, ok := err.(*url.Error)
|
var errno syscall.Errno
|
||||||
if !ok {
|
if errors.As(err, &errno) {
|
||||||
return false
|
return errno == syscall.ECONNREFUSED || errno == syscall.ECONNRESET
|
||||||
}
|
}
|
||||||
opError, ok := urlError.Err.(*net.OpError)
|
return false
|
||||||
if !ok {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
errno, ok := opError.Err.(syscall.Errno)
|
|
||||||
if !ok {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return errno == syscall.ECONNREFUSED || errno == syscall.ECONNRESET
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isTransientError(err error) bool {
|
func isTransientError(err error) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user