Skip to content

container/exec: Support ConsoleSize#43622

Merged
thaJeztah merged 1 commit into
moby:masterfrom
vvoland:3554-exec-size
Jun 24, 2022
Merged

container/exec: Support ConsoleSize#43622
thaJeztah merged 1 commit into
moby:masterfrom
vvoland:3554-exec-size

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented May 20, 2022

Relates to

Now client have the possibility to set the console size of the executed process immediately at the creation. This makes a difference for example when executing commands that output some kind of text user interface which is bounded by the console dimensions.

- What I did
Make exec accept the console size and set it for the created exec

- How I did it
Introduced ConsoleSize parameter which is copied to specs.Process that is passed to containerd.Exec

- How to verify it

  • Run the TestExecConsoleSize integration test.
  • With CLI changes you can also check with docker exec:
# resize terminal from the default size

cid=$(docker run -d ubuntu sleep infinity)

docker exec -it $cid stty size
# check if the printed size is as expected

docker exec -it $cid top -n 1
# check if top UI is rendered at the full terminal size

- Description for the changelog
Exec allows to set the console size for the exec'd process immediately when it's created

- A picture of a cute animal (not mandatory but encouraged)
dudus2

@thaJeztah thaJeztah added area/api API kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. impact/api impact/changelog labels May 27, 2022
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Sorry for the delay; I recall I had some thoughts when looking at the changes earlier, but needed to take a bit of time to try to phrase them 😅

Left my comments; happy to hear your (and other's) thoughts on them 👍

Comment thread api/types/configs.go Outdated
Comment thread client/container_exec.go Outdated
Comment thread daemon/exec.go Outdated
@vvoland vvoland force-pushed the 3554-exec-size branch 2 times, most recently from 3ec72fd to 6115c65 Compare June 15, 2022 07:28
@vvoland
Copy link
Copy Markdown
Contributor Author

vvoland commented Jun 15, 2022

CI failure is unrelated - flaky test TestSwarmLockUnlockCluster

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one suggestion, but otherwise looks good

I was writing along while reviewing, so let me push my changes as a PR against your branch

Comment thread api/types/client.go Outdated
@thaJeztah
Copy link
Copy Markdown
Member

Oh! Didn't comment here; I opened vvoland#1 with my suggestion

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thaJeztah
Copy link
Copy Markdown
Member

@ndeloof @rumpl ptal

Comment thread api/swagger.yaml Outdated
AttachStderr: true
DetachKeys: "ctrl-p,ctrl-q"
Tty: false
ConsoleSize: nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that nil is not an alias for null in YAML, so this construct would be equivalent to the JSON {"ConsoleSize": "nil"}. I don't think that's your intention. Maybe omit it entirely from the Tty: false example and provide a separate example with Tty: true and ConsoleSize set to an array, like the ExecStartConfig example below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch! See what Go does to some people... 😄
Unfortunately multiple examples seems to be supported in OpenAPI 3.0 and we use 2.0 here (https://swagger.io/docs/specification/adding-examples/).
So I'll just leave the Tty: false and remove ConsoleSize from here. So we don't repeat the same example as ExecStartConfig.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nice catch! I wanted to comment "perhaps remove this one" when I reviewed, but decided not to, and completely missed the nil vs null 😂

As to OpenAPI 3.0 - we should probably move to 3.0 at some point, but I looked into that in the past and automatic conversions weren't great (so still a lot of manual work to do to rewrite it), but also with the tooling we currently use (at least the current version of that) not really working with it, I decided that it was not worth the effort at that point (don't break what works 😅). (also see #42593)

We could of course look into it again; I recently had a discussion with some people from the Docker Hub team, who were planning to change some of their API docs to 3.0.

@thaJeztah thaJeztah added this to the 22.06.0 milestone Jun 24, 2022
Now client have the possibility to set the console size of the executed
process immediately at the creation. This makes a difference for example
when executing commands that output some kind of text user interface
which is bounded by the console dimensions.

Signed-off-by: Paweł Gronowski <[email protected]>
@thaJeztah
Copy link
Copy Markdown
Member

@crazy-max this expected? I see the windows-2019 jobs are considered "dependencies" for the failed windows-2022 job 🤔
Screenshot 2022-06-24 at 13 30 00

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all green now

still LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API impact/api impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants