mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-19 15:47:30 +00:00
Use timeout function to detect transient errors
Kubernetes-commit: a888fef242fd59bc3871c67099c7f5e9449873c2
This commit is contained in:
parent
9a88950e38
commit
583e50d008
@ -18,8 +18,10 @@ package remotecommand
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -476,12 +478,18 @@ func (h *heartbeat) start() {
|
|||||||
klog.V(8).Infof("Websocket Ping succeeeded")
|
klog.V(8).Infof("Websocket Ping succeeeded")
|
||||||
} else {
|
} else {
|
||||||
klog.Errorf("Websocket Ping failed: %v", err)
|
klog.Errorf("Websocket Ping failed: %v", err)
|
||||||
if gwebsocket.IsUnexpectedCloseError(err, gwebsocket.CloseGoingAway, gwebsocket.CloseAbnormalClosure) {
|
if errors.Is(err, gwebsocket.ErrCloseSent) {
|
||||||
return
|
// we continue because c.conn.CloseChan will manage closing the connection already
|
||||||
|
continue
|
||||||
|
} else if e, ok := err.(net.Error); ok && e.Timeout() {
|
||||||
|
// Continue, in case this is a transient failure.
|
||||||
|
// c.conn.CloseChan above will tell us when the connection is
|
||||||
|
// actually closed.
|
||||||
|
// If Temporary function hadn't been deprecated, we would have used it.
|
||||||
|
// But most of temporary errors are timeout errors anyway.
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
// Continue, in case this is a transient failure.
|
return
|
||||||
// c.conn.CloseChan above will tell us when the connection is
|
|
||||||
// actually closed.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user