mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 05:30:26 +00:00
Reset the resourceVersion so that we poll again for non-timeout errors.
This commit is contained in:
@@ -19,6 +19,9 @@ package client
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||
@@ -107,3 +110,25 @@ func (c *Client) ServerAPIVersions() (*api.APIVersions, error) {
|
||||
}
|
||||
return &v, nil
|
||||
}
|
||||
|
||||
// IsTimeout tests if this is a timeout error in the underlying transport.
|
||||
// This is unbelievably ugly.
|
||||
// See: http://stackoverflow.com/questions/23494950/specifically-check-for-timeout-error for details
|
||||
func IsTimeout(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
switch err := err.(type) {
|
||||
case *url.Error:
|
||||
if err, ok := err.Err.(net.Error); ok {
|
||||
return err.Timeout()
|
||||
}
|
||||
case net.Error:
|
||||
return err.Timeout()
|
||||
}
|
||||
|
||||
if strings.Contains(err.Error(), "use of closed network connection") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user