summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-03-26 10:54:33 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-03-26 15:15:17 -0400
commitdcabf6dd717ad495ba71d2788a64255defb852fd (patch)
treebd2ee4042feadd0b84a2b4076b2d7e948f4855b7 /pkg/bindings
parentc81e273835303664d62c4e958a7f34877c05ed49 (diff)
downloadpodman-dcabf6dd717ad495ba71d2788a64255defb852fd.tar.gz
podman-dcabf6dd717ad495ba71d2788a64255defb852fd.tar.bz2
podman-dcabf6dd717ad495ba71d2788a64255defb852fd.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>
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
+}