mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-09 14:41:31 +02:00
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>
36 lines
814 B
Go
36 lines
814 B
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package kubernetes
|
|
|
|
import (
|
|
"errors"
|
|
"io"
|
|
"net"
|
|
"syscall"
|
|
|
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
|
)
|
|
|
|
// IsRetryableError returns true if this Kubernetes API should be retried.
|
|
func IsRetryableError(err error) bool {
|
|
if apierrors.IsTimeout(err) || apierrors.IsServerTimeout(err) || apierrors.IsInternalError(err) {
|
|
return true
|
|
}
|
|
|
|
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.ECONNREFUSED) {
|
|
return true
|
|
}
|
|
|
|
var netErr net.Error
|
|
|
|
if errors.As(err, &netErr) {
|
|
if netErr.Temporary() || netErr.Timeout() {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|