mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
Prevent 2 goroutines from being leaked if proxy hangs
Signed-off-by: Ziheng Liu <lzhfromustc@gmail.com>
This commit is contained in:
parent
b6c8f4916d
commit
2ca513a15d
@ -89,10 +89,9 @@ type RuntimeOperationErrorRate struct {
|
||||
|
||||
// ProxyRequest performs a get on a node proxy endpoint given the nodename and rest client.
|
||||
func ProxyRequest(c clientset.Interface, node, endpoint string, port int) (restclient.Result, error) {
|
||||
// proxy tends to hang in some cases when Node is not ready. Add an artificial timeout for this call.
|
||||
// This will leak a goroutine if proxy hangs. #22165
|
||||
// proxy tends to hang in some cases when Node is not ready. Add an artificial timeout for this call. #22165
|
||||
var result restclient.Result
|
||||
finished := make(chan struct{})
|
||||
finished := make(chan struct{}, 1)
|
||||
go func() {
|
||||
result = c.CoreV1().RESTClient().Get().
|
||||
Resource("nodes").
|
||||
|
@ -76,8 +76,7 @@ func parseKubeletMetrics(data string) (KubeletMetrics, error) {
|
||||
|
||||
func (g *Grabber) getMetricsFromNode(nodeName string, kubeletPort int) (string, error) {
|
||||
// There's a problem with timing out during proxy. Wrapping this in a goroutine to prevent deadlock.
|
||||
// Hanging goroutine will be leaked.
|
||||
finished := make(chan struct{})
|
||||
finished := make(chan struct{}, 1)
|
||||
var err error
|
||||
var rawOutput []byte
|
||||
go func() {
|
||||
|
Loading…
Reference in New Issue
Block a user