Skip to content

Commit

Permalink
Fix client watch reestablishment handling of client-side timeouts
Browse files Browse the repository at this point in the history
Kubernetes-commit: a0f1c874d42fe79d4d6eb9108df381f10f660d14
  • Loading branch information
liggitt authored and k8s-publishing-bot committed Mar 30, 2020
1 parent 0c9ec93 commit b017a6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/util/net/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ func JoinPreservingTrailingSlash(elem ...string) string {
return result
}

// IsTimeout returns true if the given error is a network timeout error
func IsTimeout(err error) bool {
neterr, ok := err.(net.Error)
return ok && neterr != nil && neterr.Timeout()
}

// IsProbableEOF returns true if the given error resembles a connection termination
// scenario that would justify assuming that the watch is empty.
// These errors are what the Go http stack returns back to us which are general
Expand Down
2 changes: 1 addition & 1 deletion pkg/watch/streamwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (sw *StreamWatcher) receive() {
case io.ErrUnexpectedEOF:
klog.V(1).Infof("Unexpected EOF during watch stream event decoding: %v", err)
default:
if net.IsProbableEOF(err) {
if net.IsProbableEOF(err) || net.IsTimeout(err) {
klog.V(5).Infof("Unable to decode an event from the watch stream: %v", err)
} else {
sw.result <- Event{
Expand Down

0 comments on commit b017a6d

Please sign in to comment.