-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🐛 Close etcd client, connections, and data streams after each use #3513
🐛 Close etcd client, connections, and data streams after each use #3513
Conversation
/assign @ncdc |
this addresses the first part of the problem. closing the etcd client isn't enough though because the dialer leaks a SPDY connection, as I also documented in the bug. spdy multiplexes connections, and closing the etcd client will close an "inner" stream, but leaves the outer connection (the one that holds all the inner streams) remaining open. if this is not fixed, then the memory leak persists. |
dataStream is created here: and then it's returned as the stream that the etcd client uses. but |
Sounds like we should fix dial.go so |
Maybe |
either way. i embedded the value of func (..) Close() error {... }
func (..) Reset() error { ... } to also invoke p.Close() after closing the data stream. this keeps NewConn simple and focused on what it needs to do, and keeps the complexity of the wrapper in the dialer, which is already making decisions about how to deal w/ multiplexing. also, in the dialer func, where it it returns early due to errors, it should close |
269978d
to
7f2a146
Compare
While having a connection and a stream tied together defeats the purpose of multiplexing, that's what we're doing today + leaking the connection |
/milestone v0.3.9 |
this looks functionally equiv to the fix that I made in my prototype /approve |
Reviewing |
7f2a146
to
573aac5
Compare
Signed-off-by: Vince Prignano <vincepri@vmware.com>
573aac5
to
e38df08
Compare
/lgtm I'd like @randomvariable to review as well. /assign @randomvariable Please feel free to remove the hold if you're happy with it. |
/test pull-cluster-api-e2e |
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.
sgtm for me.
only a question but not blocking
} | ||
|
||
// Close the error stream right away, we're not writing to it. |
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.
For my understanding: why are we creating an error string and then closing it immediately after?
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.
my understanding is that you need to create the error stream in all cases for the websocket to function, even though for port-forwarding, it's not used. I could be wrong. It was based off of https://github.com/kubernetes/client-go/blob/master/tools/portforward/portforward.go#L324:L324
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 protocol I designed for port-forward, attach, and exec multiplexes different streams in a single connection. All of these require an error stream, which is used for communicating errors about the port-forward/attach/exec back to the client. With SPDY, either side (client or server) can close its write end of the stream. With the error stream here, the client never writes to it, so we need to create it and then "close" it, which really only closes the client's write half.
looks good, thanks for deborking. /unhold |
/retitle Close etcd client, connections, and data streams after each use |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini, jdef The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Vince Prignano vincepri@vmware.com
What this PR does / why we need it:
This PR fixes a bug where we were not closing the etcd clients after each use.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #3482
/milestone v0.3.9
/kind bug