mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Fix TestServeExecInContainerIdleTimeout flake
Remove creation of stream from TestServeExecInContainerIdleTimeout as it's not necessary to very idle timeout. Increase stream creation and ack timeouts to 30 seconds. Fixes #5628
This commit is contained in:
parent
2215a64567
commit
00e24603cb
@ -436,6 +436,8 @@ func (s *Server) handleRun(w http.ResponseWriter, req *http.Request) {
|
|||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const streamCreationTimeout = 30 * time.Second
|
||||||
|
|
||||||
// handleExec handles requests to run a command inside a container.
|
// handleExec handles requests to run a command inside a container.
|
||||||
func (s *Server) handleExec(w http.ResponseWriter, req *http.Request) {
|
func (s *Server) handleExec(w http.ResponseWriter, req *http.Request) {
|
||||||
u, err := url.ParseRequestURI(req.RequestURI)
|
u, err := url.ParseRequestURI(req.RequestURI)
|
||||||
@ -491,9 +493,8 @@ func (s *Server) handleExec(w http.ResponseWriter, req *http.Request) {
|
|||||||
|
|
||||||
conn.SetIdleTimeout(s.host.StreamingConnectionIdleTimeout())
|
conn.SetIdleTimeout(s.host.StreamingConnectionIdleTimeout())
|
||||||
|
|
||||||
// TODO find a good default timeout value
|
|
||||||
// TODO make it configurable?
|
// TODO make it configurable?
|
||||||
expired := time.NewTimer(2 * time.Second)
|
expired := time.NewTimer(streamCreationTimeout)
|
||||||
|
|
||||||
var errorStream, stdinStream, stdoutStream, stderrStream httpstream.Stream
|
var errorStream, stdinStream, stdoutStream, stderrStream httpstream.Stream
|
||||||
receivedStreams := 0
|
receivedStreams := 0
|
||||||
@ -641,7 +642,7 @@ func waitForPortForwardDataStreamAndRun(pod string, uid types.UID, errorStream h
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case dataStream = <-dataStreamChan:
|
case dataStream = <-dataStreamChan:
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(streamCreationTimeout):
|
||||||
errorStream.Write([]byte("Timed out waiting for data stream"))
|
errorStream.Write([]byte("Timed out waiting for data stream"))
|
||||||
//TODO delete from dataStreamChans[port]
|
//TODO delete from dataStreamChans[port]
|
||||||
return
|
return
|
||||||
|
@ -655,15 +655,6 @@ func TestServeExecInContainerIdleTimeout(t *testing.T) {
|
|||||||
if conn == nil {
|
if conn == nil {
|
||||||
t.Fatal("Unexpected nil connection")
|
t.Fatal("Unexpected nil connection")
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
|
||||||
|
|
||||||
h := http.Header{}
|
|
||||||
h.Set(api.StreamType, api.StreamTypeError)
|
|
||||||
stream, err := conn.CreateStream(h)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error creating input stream: %v", err)
|
|
||||||
}
|
|
||||||
defer stream.Reset()
|
|
||||||
|
|
||||||
<-conn.CloseChan()
|
<-conn.CloseChan()
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func newConnection(conn *spdystream.Connection, newStreamHandler httpstream.NewS
|
|||||||
|
|
||||||
// createStreamResponseTimeout indicates how long to wait for the other side to
|
// createStreamResponseTimeout indicates how long to wait for the other side to
|
||||||
// acknowledge the new stream before timing out.
|
// acknowledge the new stream before timing out.
|
||||||
const createStreamResponseTimeout = 2 * time.Second
|
const createStreamResponseTimeout = 30 * time.Second
|
||||||
|
|
||||||
// Close first sends a reset for all of the connection's streams, and then
|
// Close first sends a reset for all of the connection's streams, and then
|
||||||
// closes the underlying spdystream.Connection.
|
// closes the underlying spdystream.Connection.
|
||||||
|
Loading…
Reference in New Issue
Block a user