Fix stream timeout defaults

This was an unintentional breaking change in
0bdf742303

A timeout of 0 doesn't make any sense, so use the old values of 30s as a
default.
This commit is contained in:
Brian Goff
2020-06-03 10:01:34 -07:00
parent 8fc8b69d8f
commit 51b9a6c40d

View File

@@ -91,6 +91,14 @@ func HandleContainerExec(h ContainerExecHandlerFunc, opts ...ContainerExecHandle
for _, o := range opts { for _, o := range opts {
o(&cfg) o(&cfg)
} }
if cfg.StreamIdleTimeout == 0 {
cfg.StreamIdleTimeout = 30 * time.Second
}
if cfg.StreamCreationTimeout == 0 {
cfg.StreamCreationTimeout = 30 * time.Second
}
return handleError(func(w http.ResponseWriter, req *http.Request) error { return handleError(func(w http.ResponseWriter, req *http.Request) error {
vars := mux.Vars(req) vars := mux.Vars(req)
@@ -108,6 +116,7 @@ func HandleContainerExec(h ContainerExecHandlerFunc, opts ...ContainerExecHandle
return errdefs.AsInvalidInput(err) return errdefs.AsInvalidInput(err)
} }
// TODO: Why aren't we using req.Context() here?
ctx, cancel := context.WithCancel(context.TODO()) ctx, cancel := context.WithCancel(context.TODO())
defer cancel() defer cancel()