mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Merge pull request #9890 from ncdc/fix-exec-infinite-loop
Eliminate possible infinite loop in exec
This commit is contained in:
commit
f7cb6e9844
@ -25,6 +25,7 @@ import (
|
|||||||
|
|
||||||
kubecontainer "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
|
kubecontainer "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
|
||||||
docker "github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExecHandler knows how to execute a command in a running Docker container.
|
// ExecHandler knows how to execute a command in a running Docker container.
|
||||||
@ -123,6 +124,7 @@ func (*NativeExecHandler) ExecInContainer(client DockerInterface, container *doc
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tick := time.Tick(2 * time.Second)
|
tick := time.Tick(2 * time.Second)
|
||||||
|
count := 0
|
||||||
for {
|
for {
|
||||||
inspect, err2 := client.InspectExec(execObj.ID)
|
inspect, err2 := client.InspectExec(execObj.ID)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
@ -134,6 +136,13 @@ func (*NativeExecHandler) ExecInContainer(client DockerInterface, container *doc
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count++
|
||||||
|
if count == 5 {
|
||||||
|
glog.Errorf("Exec session %s in container %s terminated but process still running!", execObj.ID, container.ID)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
<-tick
|
<-tick
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user