Merge pull request #10683 from Luap99/exec-resize

Fix resize race with podman exec -it
This commit is contained in:
OpenShift Merge Robot
2021-06-16 15:29:34 -04:00
committed by GitHub
12 changed files with 96 additions and 31 deletions

View File

@ -178,8 +178,16 @@ func ExecStartHandler(w http.ResponseWriter, r *http.Request) {
logrus.Error(errors.Wrapf(e, "error attaching to container %s exec session %s", sessionCtr.ID(), sessionID))
}
var size *define.TerminalSize
if bodyParams.Tty && (bodyParams.Height > 0 || bodyParams.Width > 0) {
size = &define.TerminalSize{
Height: bodyParams.Height,
Width: bodyParams.Width,
}
}
hijackChan := make(chan bool, 1)
err = sessionCtr.ExecHTTPStartAndAttach(sessionID, r, w, nil, nil, nil, hijackChan)
err = sessionCtr.ExecHTTPStartAndAttach(sessionID, r, w, nil, nil, nil, hijackChan, size)
if <-hijackChan {
// If connection was Hijacked, we have to signal it's being closed

View File

@ -73,7 +73,7 @@ func ResizeTTY(w http.ResponseWriter, r *http.Request) {
return
}
if err := ctnr.ExecResize(name, sz); err != nil {
if errors.Cause(err) != define.ErrCtrStateInvalid || !query.IgnoreNotRunning {
if errors.Cause(err) != define.ErrExecSessionStateInvalid || !query.IgnoreNotRunning {
utils.InternalServerError(w, errors.Wrapf(err, "cannot resize session"))
return
}

View File

@ -157,8 +157,10 @@ type ExecCreateResponse struct {
}
type ExecStartConfig struct {
Detach bool `json:"Detach"`
Tty bool `json:"Tty"`
Detach bool `json:"Detach"`
Tty bool `json:"Tty"`
Height uint16 `json:"h"`
Width uint16 `json:"w"`
}
func ImageToImageSummary(l *libimage.Image) (*entities.ImageSummary, error) {

View File

@ -269,10 +269,16 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error {
// properties:
// Detach:
// type: boolean
// description: Detach from the command. Not presently supported.
// description: Detach from the command.
// Tty:
// type: boolean
// description: Allocate a pseudo-TTY. Presently ignored.
// description: Allocate a pseudo-TTY.
// h:
// type: integer
// description: Height of the TTY session in characters. Tty must be set to true to use it.
// w:
// type: integer
// description: Width of the TTY session in characters. Tty must be set to true to use it.
// produces:
// - application/json
// responses: