Skip to content

Commit

Permalink
fix: check retryable network errors by interface
Browse files Browse the repository at this point in the history
Looks like tls errors implement the interface, but they are not derived
from the `*net.OpError`, so this check should catch more errors.

Fixes #3457

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Apr 12, 2021
1 parent 767f3b9 commit e26c977
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/kubernetes/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ func IsRetryableError(err error) bool {
return true
}

if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.ECONNREFUSED) {
return true
}

netErr := &net.OpError{}
var netErr net.Error

if errors.As(err, &netErr) {
return netErr.Temporary() || netErr.Timeout() || errors.Is(netErr.Err, syscall.ECONNREFUSED)
if netErr.Temporary() || netErr.Timeout() {
return true
}
}

return false
Expand Down

0 comments on commit e26c977

Please sign in to comment.