diff --git a/pkg/kubelet/server.go b/pkg/kubelet/server.go index 08be664dcab..6747f0977d4 100644 --- a/pkg/kubelet/server.go +++ b/pkg/kubelet/server.go @@ -436,6 +436,8 @@ func (s *Server) handleRun(w http.ResponseWriter, req *http.Request) { w.Write(data) } +const streamCreationTimeout = 30 * time.Second + // handleExec handles requests to run a command inside a container. func (s *Server) handleExec(w http.ResponseWriter, req *http.Request) { 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()) - // TODO find a good default timeout value // TODO make it configurable? - expired := time.NewTimer(2 * time.Second) + expired := time.NewTimer(streamCreationTimeout) var errorStream, stdinStream, stdoutStream, stderrStream httpstream.Stream receivedStreams := 0 @@ -641,7 +642,7 @@ func waitForPortForwardDataStreamAndRun(pod string, uid types.UID, errorStream h select { case dataStream = <-dataStreamChan: - case <-time.After(1 * time.Second): + case <-time.After(streamCreationTimeout): errorStream.Write([]byte("Timed out waiting for data stream")) //TODO delete from dataStreamChans[port] return diff --git a/pkg/kubelet/server_test.go b/pkg/kubelet/server_test.go index 02c2ec8f096..935cd6df408 100644 --- a/pkg/kubelet/server_test.go +++ b/pkg/kubelet/server_test.go @@ -655,15 +655,6 @@ func TestServeExecInContainerIdleTimeout(t *testing.T) { if conn == nil { 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() } diff --git a/pkg/util/httpstream/spdy/connection.go b/pkg/util/httpstream/spdy/connection.go index 46792427891..cc473d6762a 100644 --- a/pkg/util/httpstream/spdy/connection.go +++ b/pkg/util/httpstream/spdy/connection.go @@ -71,7 +71,7 @@ func newConnection(conn *spdystream.Connection, newStreamHandler httpstream.NewS // createStreamResponseTimeout indicates how long to wait for the other side to // 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 // closes the underlying spdystream.Connection.