mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
Use timeout function to detect transient errors
This commit is contained in:
parent
914210ee9a
commit
a888fef242
@ -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.
|
// Continue, in case this is a transient failure.
|
||||||
// c.conn.CloseChan above will tell us when the connection is
|
// c.conn.CloseChan above will tell us when the connection is
|
||||||
// actually closed.
|
// actually closed.
|
||||||
|
// If Temporary function hadn't been deprecated, we would have used it.
|
||||||
|
// But most of temporary errors are timeout errors anyway.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user