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

feature: support resize the tty of cri exec process #2063

Merged
merged 1 commit into from
Aug 8, 2018

Conversation

YaoZengzeng
Copy link
Contributor

@YaoZengzeng YaoZengzeng commented Aug 7, 2018

Signed-off-by: YaoZengzeng yaozengzeng@zju.edu.cn

Ⅰ. Describe what this PR did

  1. Get resize request from resize stream

  2. Put the resize request to channel

  3. Spawn goroutine to process the request from channel

  4. Call the container manager's ResizeExec method

  5. Call the ctrd's ResizeExec method

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@YaoZengzeng YaoZengzeng changed the title feature: exec resize feature: support resize the tty of cri exec process Aug 7, 2018
@codecov-io
Copy link

codecov-io commented Aug 7, 2018

Codecov Report

Merging #2063 into master will increase coverage by 5.01%.
The diff coverage is 63.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2063      +/-   ##
==========================================
+ Coverage   58.74%   63.76%   +5.01%     
==========================================
  Files         202      202              
  Lines       15535    15621      +86     
==========================================
+ Hits         9126     9960     +834     
+ Misses       5301     4418     -883     
- Partials     1108     1243     +135
Flag Coverage Δ
#criv1alpha1test 33.49% <37.89%> (-0.22%) ⬇️
#criv1alpha2test 34.17% <62.1%> (?)
#integrationtest 38.24% <1.05%> (-0.24%) ⬇️
#unittest 23.11% <0%> (-0.05%) ⬇️
Impacted Files Coverage Δ
daemon/mgr/container.go 53.73% <ø> (-0.16%) ⬇️
daemon/mgr/container_exec.go 67.32% <0%> (-3.51%) ⬇️
cri/stream/remotecommand/exec.go 36.66% <100%> (ø) ⬆️
ctrd/container.go 47.49% <11.11%> (-2.69%) ⬇️
cri/stream/runtime.go 68.23% <56.25%> (-3.2%) ⬇️
cri/stream/remotecommand/httpstream.go 44.04% <76.56%> (-5.59%) ⬇️
ctrd/image.go 79.31% <0%> (-1.98%) ⬇️
cri/v1alpha1/cri.go 65.18% <0%> (-0.18%) ⬇️
... and 10 more

@YaoZengzeng
Copy link
Contributor Author

@fuweid @HusterWan PTAL


// SupportedStreamingProtocols is the streaming protocols which server supports.
var SupportedStreamingProtocols = []string{constant.StreamProtocolV1Name, constant.StreamProtocolV2Name}
var SupportedStreamingProtocols = []string{constant.StreamProtocolV1Name, constant.StreamProtocolV2Name, constant.StreamProtocolV3Name}
Copy link
Contributor

Choose a reason for hiding this comment

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

could we fold this line? I think it is readable if one option is in one line.

for {
size := apitypes.ResizeOptions{}
err := decoder.Decode(&size)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

if the err is not EOF, I think we should show the warning message.


return ctx, true
}

func handleResizeEvents(stream io.Reader, channel chan<- apitypes.ResizeOptions) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could we add the ctx or event id for log stuff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems we can't provide enough useful information in this function

So I do the log in function handleResizing from which we could know the container and exec id

}
go func() {
for {
size, ok := <-resizeChan
Copy link
Contributor

Choose a reason for hiding this comment

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

the size is always valid?

replyChan := make(chan struct{})
stop := make(chan struct{})
defer close(stop)
WaitForStreams:
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 change the break label here? it looks like the function name...

@YaoZengzeng
Copy link
Contributor Author

@fuweid Updated.

Signed-off-by: YaoZengzeng <yaozengzeng@zju.edu.cn>
Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

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

Successfully merging this pull request may close these issues.

4 participants