Skip to content

Conversation

@starnop
Copy link
Contributor

@starnop starnop commented Jul 12, 2018

Signed-off-by: Starnop [email protected]

Ⅰ. Describe what this PR did

For now,The organization of the code about stream Manager is unreasonable,we should reorganize the file structure: extract stream manager as the public part.

Ⅱ. Does this pull request fix one issue?

fixes part of #1524

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@starnop starnop force-pushed the cri-stream-manager branch 2 times, most recently from 6ac64ba to fc71fc7 Compare July 12, 2018 09:13
@codecov-io
Copy link

codecov-io commented Jul 12, 2018

Codecov Report

Merging #1725 into master will decrease coverage by 2.29%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #1725     +/-   ##
=========================================
- Coverage   41.76%   39.46%   -2.3%     
=========================================
  Files         278      277      -1     
  Lines       18244    19258   +1014     
=========================================
- Hits         7619     7601     -18     
- Misses       9699    10719   +1020     
- Partials      926      938     +12
Impacted Files Coverage Δ
cri/stream/remotecommand/exec.go 0% <0%> (ø) ⬆️
cri/v1alpha2/server.go 0% <0%> (ø) ⬆️
cri/stream/runtime.go 0% <0%> (ø)
cri/v1alpha1/cri_stream.go 0% <0%> (ø) ⬆️
cri/stream/portforward/portforward.go 0% <0%> (ø) ⬆️
cri/v1alpha1/server.go 0% <0%> (ø) ⬆️
cri/stream/portforward/httpstream.go 0% <0%> (ø) ⬆️
cri/v1alpha2/cri_stream.go 0% <0%> (ø) ⬆️
cri/stream/remotecommand/attach.go 0% <0%> (ø) ⬆️
apis/opts/oom_score.go 0% <0%> (-100%) ⬇️
... and 20 more

@allencloud
Copy link
Collaborator

Sounds good to me, while I still wish @YaoZengzeng @fuweid could take a review for this.

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.

The change is acceptable and reasonable. But there needs little change in this commit. Please take a look.

package stream

import (
"github.com/alibaba/pouch/cri/stream/constant"
Copy link
Contributor

Choose a reason for hiding this comment

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

split packages into two groups~

// Address is the addr:port address the server will listen on.
Address string

// BaseURL is the optional base URL for constructing streaming URLs. If empty, the baseURL will be constructed from the serve address.
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 the comment into two lines, since this line is too long? 😄


// DefaultConfig provides default values for server Config.
var DefaultConfig = Config{
StreamIdleTimeout: 4 * time.Hour,
Copy link
Contributor

Choose a reason for hiding this comment

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

use DefaultStreamIdleTimeout instead of 4*time.Hour ?

}

// Exec executes a command inside the container.
func (s *streamRuntime) Exec(containerID string, cmd []string, streamOpts *remotecommand.Options, streams *remotecommand.Streams) (uint32, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add the context as first argument? If we have the ctx, we can handle the progress by the upstream.

@starnop starnop force-pushed the cri-stream-manager branch 4 times, most recently from f622d61 to bddb6e6 Compare July 16, 2018 02:14
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.

package portforward

import (
con "context"
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 use the context here to make the word readable, because the con might be the connection.

}

func handleHTTPStreams(w http.ResponseWriter, req *http.Request, portForwarder PortForwarder, podName string, idleTimeout, streamCreationTimeout time.Duration, supportedPortForwardProtocols []string) error {
func handleHTTPStreams(cont con.Context, w http.ResponseWriter, req *http.Request, portForwarder PortForwarder, podName string, idleTimeout, streamCreationTimeout time.Duration, supportedPortForwardProtocols []string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

the var of context.Context can be named by ctx.

// connections; i.e., multiple `curl http://localhost:8888/` requests will be
// handled by a single invocation of ServePortForward.
func ServePortForward(w http.ResponseWriter, req *http.Request, portForwarder PortForwarder, podName string, idleTimeout time.Duration, streamCreationTimeout time.Duration, supportedProtocols []string) {
func ServePortForward(cont con.Context, w http.ResponseWriter, req *http.Request, portForwarder PortForwarder, podName string, idleTimeout time.Duration, streamCreationTimeout time.Duration, supportedProtocols []string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

for the name rule, please check the last comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All mentioned above is because there's a structure called context, we could renamed it in the next PR.

return fmt.Errorf("failed to attach to container %q: %v", containerID, err)
}

<-streams.StreamCh
Copy link
Contributor

Choose a reason for hiding this comment

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

The channel is just used for the notify event?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@fuweid Yes, it is used to notify the container io has been closed and then the Attach function could return, the http connection could be closed.

Copy link
Contributor

Choose a reason for hiding this comment

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

roger

}

func (s *server) serveExec(w http.ResponseWriter, r *http.Request) {
ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

we can use r.Context() instead of context.Background().

@starnop starnop force-pushed the cri-stream-manager branch from bddb6e6 to ac2ce18 Compare July 16, 2018 06:17
@starnop starnop force-pushed the cri-stream-manager branch from ac2ce18 to 206c597 Compare July 16, 2018 06:21
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 @YaoZengzeng please help us to check again.

@YaoZengzeng
Copy link
Contributor

LGTM

@allencloud allencloud merged commit adb8ce1 into AliyunContainerService:master Jul 16, 2018
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.

6 participants