summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/resize.go
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-06-03 16:07:43 +0200
committerPaul Holzinger <pholzing@redhat.com>2021-06-04 16:55:48 +0200
commit1f73374acd3c33d1884e9383205c9f891a3552db (patch)
tree95ed36dbd4022c772a3be26d2c8205ba9ec6507c /pkg/api/handlers/compat/resize.go
parent52dae693da0df1447b7f5210a4c842d5c5a8a401 (diff)
downloadpodman-1f73374acd3c33d1884e9383205c9f891a3552db.tar.gz
podman-1f73374acd3c33d1884e9383205c9f891a3552db.tar.bz2
podman-1f73374acd3c33d1884e9383205c9f891a3552db.zip
remote: always send resize before the container starts
There is race condition in the remote client attach logic. Because the resize api call was handled in an extra goroutine the container was started before the resize call happend. To fix this we have to call resize in the same goroutine as attach. When the first resize is done start a goroutine to listen on SIGWINCH in the background and resize again if the signal is received. Fixes #9859 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'pkg/api/handlers/compat/resize.go')
-rw-r--r--pkg/api/handlers/compat/resize.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/pkg/api/handlers/compat/resize.go b/pkg/api/handlers/compat/resize.go
index 23ed33a22..f65e313fc 100644
--- a/pkg/api/handlers/compat/resize.go
+++ b/pkg/api/handlers/compat/resize.go
@@ -46,20 +46,13 @@ func ResizeTTY(w http.ResponseWriter, r *http.Request) {
utils.ContainerNotFound(w, name, err)
return
}
- if state, err := ctnr.State(); err != nil {
- utils.InternalServerError(w, errors.Wrapf(err, "cannot obtain container state"))
- return
- } else if state != define.ContainerStateRunning && !query.IgnoreNotRunning {
- utils.Error(w, "Container not running", http.StatusConflict,
- fmt.Errorf("container %q in wrong state %q", name, state.String()))
- return
- }
- // If container is not running, ignore since this can be a race condition, and is expected
if err := ctnr.AttachResize(sz); err != nil {
- if errors.Cause(err) != define.ErrCtrStateInvalid || !query.IgnoreNotRunning {
+ if errors.Cause(err) != define.ErrCtrStateInvalid {
utils.InternalServerError(w, errors.Wrapf(err, "cannot resize container"))
- return
+ } else {
+ utils.Error(w, "Container not running", http.StatusConflict, err)
}
+ return
}
// This is not a 204, even though we write nothing, for compatibility
// reasons.