Reset the resourceVersion so that we poll again for non-timeout errors.

This commit is contained in:
Brendan Burns
2015-01-06 11:36:03 -08:00
parent 4432ba06bd
commit 0f60d7bca3
3 changed files with 77 additions and 0 deletions

View File

@@ -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
}