-
Notifications
You must be signed in to change notification settings - Fork 38.8k
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
WebSocket Client and V5 RemoteCommand Subprotocol #119157
Conversation
/sig api-machinery |
/priority important-soon |
/cc @aojea |
ae80a42
to
ec34bf5
Compare
/retest |
1 similar comment
/retest |
/cc @jpbetz |
LGTM some questions that. may be follow ups if they make sense |
/lgtm |
LGTM label has been added. Git tree hash: e63541a9b1e44c41bd81732a42f56e4a220c19c1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
/hold for one question about the websocket impl matching the spdy impl lack of thread safety
} | ||
|
||
// NewWebSocketExecutor allows to execute commands via a WebSocket connection. | ||
func NewWebSocketExecutor(config *restclient.Config, method, url string) (Executor, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the returned executor's Stream / StreamWithContext methods are not threadsafe, right? I think the spdy executor has the same issue (due to the coupled upgrader storing state during the connection setup) but can you verify that? would be good to explicitly document that here and on the spdy constructor, but it's fine if that goes into a follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. You are correct that neither the SPDY nor WebSocket Stream/StreamWithContext
are thread-safe for a single executor. As you mention, the UpgradeRoundTripper
for both store state (the dialed/created connection). SPDY already has some documentation related to this when defining the SpdyRoundTripper
struct. Above the connection field is the following comment
type SpdyRoundTripper struct {
...
/* TODO according to http://golang.org/pkg/net/http/#RoundTripper, a RoundTripper
must be safe for use by multiple concurrent goroutines. If this is absolutely
necessary, we could keep a map from http.Request to net.Conn. In practice,
a client will create an http.Client, set the transport to a new insteace of
SpdyRoundTripper, and use it a single time, so this hopefully won't be an issue.
*/
// conn is the underlying network connection to the remote server.
conn net.Conn
I have added documentation about the lack of thread safety to WebSocket.Stream/StreamWithContext
29bac76
to
a0d6a81
Compare
/retest unrelated required test failure |
/lgtm |
LGTM label has been added. Git tree hash: 4cf19be17ea27119104412468df71489446462a9
|
@liggitt it is on hold and the approve label was not added |
/hold cancel |
WebSocketExecutor
. The executor is not yet called by any client.doc.go
inwsstream
package describes every version of binary WebSockets RemoteCommand protocols.tools/remotecommand
test coverage from53.8%
to75.5%
.k8s.io/client-go/tools/remotecommmand/websocket.go
has test coverage:88.3%
Example stress test for WebSocket client testing STDIN and STDOUT stream
This loopback test sends 1MB of random data onto the STDIN stream copying the data back to the client onto the STDOUT stream.
Example stress test for WebSocket client sending multiple write streams concurrently (STDIN, TTY Resize)
/kind feature
Helps fix: #89163
NOTE: WebSocket client is implemented with the Gorilla WebSockets library
RoundTripper
, because they return an http response which is part of theRoundTripper
interface when other libraries do not.