summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-03-26 10:54:33 -0400
committerMatthew Heon <mheon@redhat.com>2021-03-29 11:16:51 -0400
commitb5573018073b22b923d88efc853f8f1c35ca8119 (patch)
tree412e5f86e430293a40a397c0c20555921782470e /pkg/bindings
parente7dc66d832d44eac11cb341f09844850e3e0224d (diff)
downloadpodman-b5573018073b22b923d88efc853f8f1c35ca8119.tar.gz
podman-b5573018073b22b923d88efc853f8f1c35ca8119.tar.bz2
podman-b5573018073b22b923d88efc853f8f1c35ca8119.zip
Remove resize race condition
Since podman-remote resize requests can come in at random times, this generates a real potential for race conditions. We should only be attempting to resize TTY on running containers, but the containers can go from running to stopped at any time, and returning an error to the caller is just causing noice. This change will basically ignore requests to resize terminals if the container is not running and return the caller to success. All other callers will still return failure. Fixes: https://github.com/containers/podman/issues/9831 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> <MH: Fixed cherry-pick conflicts> Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/containers/attach.go1
-rw-r--r--pkg/bindings/containers/types.go5
-rw-r--r--pkg/bindings/containers/types_resizetty_options.go16
3 files changed, 20 insertions, 2 deletions
diff --git a/pkg/bindings/containers/attach.go b/pkg/bindings/containers/attach.go
index ecae22a1b..fd8a7011d 100644
--- a/pkg/bindings/containers/attach.go
+++ b/pkg/bindings/containers/attach.go
@@ -307,6 +307,7 @@ func resizeTTY(ctx context.Context, endpoint string, height *int, width *int) er
if width != nil {
params.Set("w", strconv.Itoa(*width))
}
+ params.Set("running", "true")
rsp, err := conn.DoRequest(nil, http.MethodPost, endpoint, params, nil)
if err != nil {
return err
diff --git a/pkg/bindings/containers/types.go b/pkg/bindings/containers/types.go
index 2d0e65bb4..f63e35bf1 100644
--- a/pkg/bindings/containers/types.go
+++ b/pkg/bindings/containers/types.go
@@ -210,8 +210,9 @@ type RenameOptions struct {
// ResizeTTYOptions are optional options for resizing
// container TTYs
type ResizeTTYOptions struct {
- Height *int
- Width *int
+ Height *int
+ Width *int
+ Running *bool
}
//go:generate go run ../generator/generator.go ResizeExecTTYOptions
diff --git a/pkg/bindings/containers/types_resizetty_options.go b/pkg/bindings/containers/types_resizetty_options.go
index 68527b330..94946692f 100644
--- a/pkg/bindings/containers/types_resizetty_options.go
+++ b/pkg/bindings/containers/types_resizetty_options.go
@@ -51,3 +51,19 @@ func (o *ResizeTTYOptions) GetWidth() int {
}
return *o.Width
}
+
+// WithRunning
+func (o *ResizeTTYOptions) WithRunning(value bool) *ResizeTTYOptions {
+ v := &value
+ o.Running = v
+ return o
+}
+
+// GetRunning
+func (o *ResizeTTYOptions) GetRunning() bool {
+ var running bool
+ if o.Running == nil {
+ return running
+ }
+ return *o.Running
+}