summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/resize.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-28 20:12:08 -0400
committerGitHub <noreply@github.com>2020-05-28 20:12:08 -0400
commitcd1e25f5d57059a50e8aeae5b640c2d282e70f96 (patch)
treec5fe7993722f72f96b2f49b1ce47e2bb99adc531 /pkg/api/handlers/compat/resize.go
parente8818ced806910f8ce44939fef08f89139be4119 (diff)
parent5626c2163bff661540e1ae3a5df25f0c7e7573f6 (diff)
downloadpodman-cd1e25f5d57059a50e8aeae5b640c2d282e70f96.tar.gz
podman-cd1e25f5d57059a50e8aeae5b640c2d282e70f96.tar.bz2
podman-cd1e25f5d57059a50e8aeae5b640c2d282e70f96.zip
Merge pull request #6420 from jwhonce/wip/json
V2 verify JSON output is consistent and doesn't drift
Diffstat (limited to 'pkg/api/handlers/compat/resize.go')
-rw-r--r--pkg/api/handlers/compat/resize.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/api/handlers/compat/resize.go b/pkg/api/handlers/compat/resize.go
index 3ead733bc..231b53175 100644
--- a/pkg/api/handlers/compat/resize.go
+++ b/pkg/api/handlers/compat/resize.go
@@ -1,10 +1,12 @@
package compat
import (
+ "fmt"
"net/http"
"strings"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/api/handlers/utils"
"github.com/gorilla/schema"
"github.com/pkg/errors"
@@ -43,6 +45,14 @@ 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 {
+ utils.Error(w, "Container not running", http.StatusConflict,
+ fmt.Errorf("container %q in wrong state %q", name, state.String()))
+ return
+ }
if err := ctnr.AttachResize(sz); err != nil {
utils.InternalServerError(w, errors.Wrapf(err, "cannot resize container"))
return
@@ -56,6 +66,14 @@ func ResizeTTY(w http.ResponseWriter, r *http.Request) {
utils.SessionNotFound(w, name, err)
return
}
+ if state, err := ctnr.State(); err != nil {
+ utils.InternalServerError(w, errors.Wrapf(err, "cannot obtain session container state"))
+ return
+ } else if state != define.ContainerStateRunning {
+ utils.Error(w, "Container not running", http.StatusConflict,
+ fmt.Errorf("container %q in wrong state %q", name, state.String()))
+ return
+ }
if err := ctnr.ExecResize(name, sz); err != nil {
utils.InternalServerError(w, errors.Wrapf(err, "cannot resize session"))
return