Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: align with docker v1.24 API #1226

Merged
merged 1 commit into from
Apr 27, 2018
Merged

bugfix: align with docker v1.24 API #1226

merged 1 commit into from
Apr 27, 2018

Conversation

fuweid
Copy link
Contributor

@fuweid fuweid commented Apr 26, 2018

The docker exec api uses custom stream bytes if the tty is false.
In order to align with docker API, we need to use
github.com/docker/docker/pkg/stdcopy package to modify stream bytes.

Signed-off-by: Wei Fu [email protected]

Ⅰ. Describe what this PR did

Align with docker v1.24 API. As we known, the docker API has custom stream bytes when the client doesn't set tty. More information is here: https://github.com/moby/moby/blob/master/client/container_attach.go#L10-L33

Ⅱ. Does this pull request fix one issue?

Fix #1221

Ⅲ. Describe how you did it

use github.com/docker/docker/pkg/stdcopy to wrap the io.Writer.

Ⅳ. Describe how to verify it

➜  docker ./docker -H unix:///var/run/pouchd.sock exec -i 05e7c1b71cf63137fbac112f5ab2c5a6d9002c938aca304e259507b9c4aec66c ls
Unrecognized input header: 98

after fix:

➜  docker ./docker -H unix:///var/run/pouchd.sock exec -i 05e7c1b71cf63137fbac112f5ab2c5a6d9002c938aca304e259507b9c4aec66c ls
bin
dev
etc
home
proc
root
run
sys
tmp
usr
var

Ⅴ. Special notes for reviews

@allencloud @HusterWan @yyb196 This change is not ideal. We need to refactor the IO related things.

@pouchrobot pouchrobot added kind/bug This is bug report for project size/XL labels Apr 26, 2018
defer func() {
if err := restoreMode(in, out); err != nil {
fmt.Fprintf(os.Stderr, "failed to restore term mode")
if e.Terminal {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the command doesn't set tty, we don't need to set raw mode for terminal

@@ -493,6 +493,12 @@
"revision": "53a58da551e961b3710bbbdfabbc162c3f5f30f6",
"revisionTime": "2018-01-31T23:13:00Z"
},
{
"checksumSHA1": "H1rrbVmeE1z2TnkF7tSrfh+qUOY=",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we let docker vendor pkg version be same ? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HusterWan Yes. It's already "53a58da551e961b3710bbbdfabbc162c3f5f30f6"

@@ -95,19 +96,26 @@ func (e *ExecCommand) runExec(args []string) error {
wg.Add(1)
go func() {
defer wg.Done()
io.Copy(os.Stdout, reader)
if !e.Terminal {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add some test case for exec command -i and -it flags

we can add the test case later, because this feature is needed very hurry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure thing.

@fuweid fuweid changed the title bugfix: align with docker v1.24 API [wip] bugfix: align with docker v1.24 API Apr 26, 2018
The docker exec api uses custom stream bytes if the tty is false. In order
to align with docker API, we need to use
github.com/docker/docker/pkg/stdcopy package to modify stream bytes.

In order to make the cri CI happy, we should skip the related `echo`
test.

Signed-off-by: Wei Fu <[email protected]>
@codecov-io
Copy link

Codecov Report

Merging #1226 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1226      +/-   ##
==========================================
- Coverage   15.37%   15.36%   -0.02%     
==========================================
  Files         172      172              
  Lines       10619    10629      +10     
==========================================
  Hits         1633     1633              
- Misses       8866     8876      +10     
  Partials      120      120
Impacted Files Coverage Δ
cli/exec.go 0% <0%> (ø) ⬆️
ctrd/container.go 0% <0%> (ø) ⬆️

@fuweid fuweid changed the title [wip] bugfix: align with docker v1.24 API bugfix: align with docker v1.24 API Apr 27, 2018
@HusterWan
Copy link
Contributor

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Apr 27, 2018
@HusterWan HusterWan merged commit 98ec8f3 into AliyunContainerService:master Apr 27, 2018
@fuweid fuweid deleted the bugfix_hijack_io branch April 27, 2018 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] exec is not compitable with moby
4 participants