diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-04-06 17:04:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 17:04:50 +0200 |
commit | 382b5b81d24870abe400d14296e4f5ef47c99d29 (patch) | |
tree | 05d4173fd7095cf10df6ea7f89ab5202200daad8 /libpod/container_exec.go | |
parent | f143de9db6861cd8b8d6fc4e03f2826041307982 (diff) | |
parent | 541252afa701850f6691933d575c5c24ed0b17c1 (diff) | |
download | podman-382b5b81d24870abe400d14296e4f5ef47c99d29.tar.gz podman-382b5b81d24870abe400d14296e4f5ef47c99d29.tar.bz2 podman-382b5b81d24870abe400d14296e4f5ef47c99d29.zip |
Merge pull request #9942 from mheon/fix_9919
Ensure that `--userns=keep-id` sets user in config
Diffstat (limited to 'libpod/container_exec.go')
-rw-r--r-- | libpod/container_exec.go | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/libpod/container_exec.go b/libpod/container_exec.go index bb43287d9..8d8ed14aa 100644 --- a/libpod/container_exec.go +++ b/libpod/container_exec.go @@ -696,6 +696,24 @@ func (c *Container) ExecResize(sessionID string, newSize define.TerminalSize) er return errors.Wrapf(define.ErrExecSessionStateInvalid, "cannot resize container %s exec session %s as it is not running", c.ID(), session.ID()) } + // The exec session may have exited since we last updated. + // Needed to prevent race conditions around short-running exec sessions. + running, err := c.ociRuntime.ExecUpdateStatus(c, session.ID()) + if err != nil { + return err + } + if !running { + session.State = define.ExecStateStopped + + if err := c.save(); err != nil { + logrus.Errorf("Error saving state of container %s: %v", c.ID(), err) + } + + return errors.Wrapf(define.ErrExecSessionStateInvalid, "cannot resize container %s exec session %s as it has stopped", c.ID(), session.ID()) + } + + // Make sure the exec session is still running. + return c.ociRuntime.ExecAttachResize(c, sessionID, newSize) } @@ -720,8 +738,13 @@ func (c *Container) Exec(config *ExecConfig, streams *define.AttachStreams, resi logrus.Debugf("Sending resize events to exec session %s", sessionID) for resizeRequest := range resize { if err := c.ExecResize(sessionID, resizeRequest); err != nil { - // Assume the exec session went down. - logrus.Warnf("Error resizing exec session %s: %v", sessionID, err) + if errors.Cause(err) == define.ErrExecSessionStateInvalid { + // The exec session stopped + // before we could resize. + logrus.Infof("Missed resize on exec session %s, already stopped", sessionID) + } else { + logrus.Warnf("Error resizing exec session %s: %v", sessionID, err) + } return } } |