-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Minor refactoring on the keepAliveListener and keepAliveConn #14356
Conversation
367dd40
to
6ef2a40
Compare
cc @spzala |
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.
@ahrtr great, thank you! I have few nits inline.
The proxy must be waiting for the etcd to be running, but the current implementation hard codes the wating time as 5 seconds. The improvement is to dynamically check whether the etcd is running, and start the proxy when etcd port is reachable. Signed-off-by: Benjamin Wang <wachao@vmware.com>
Only `net.TCPConn` supports `SetKeepAlive` and `SetKeepAlivePeriod` by default, so if you want to warp multiple layers of net.Listener, the `keepaliveListener` should be the one which is closest to the original `net.Listener` implementation, namely `TCPListener`. Signed-off-by: Benjamin Wang <wachao@vmware.com>
6ef2a40
to
7450673
Compare
Thanks @spzala for the quick review, and I resolved all the comments. PTAL, thx |
Codecov Report
@@ Coverage Diff @@
## main #14356 +/- ##
==========================================
- Coverage 75.44% 75.26% -0.19%
==========================================
Files 457 457
Lines 37122 37139 +17
==========================================
- Hits 28007 27952 -55
- Misses 7361 7418 +57
- Partials 1754 1769 +15
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Only `net.TCPConn` supports `SetKeepAlive` and `SetKeepAlivePeriod` by default, so if you want to warp multiple layers of net.Listener, the `keepaliveListener` should be the one which is closest to the original `net.Listener` implementation, namely `TCPListener`. Also refer to etcd-io#14356 Signed-off-by: Benjamin Wang <wachao@vmware.com>
…eListener and keepAliveConn Refer to etcd-io#14366, Also refer to etcd-io#14356 Signed-off-by: Benjamin Wang <wachao@vmware.com>
Only `net.TCPConn` supports `SetKeepAlive` and `SetKeepAlivePeriod` by default, so if you want to warp multiple layers of net.Listener, the `keepaliveListener` should be the one which is closest to the original `net.Listener` implementation, namely `TCPListener`. Also refer to etcd-io#14356 Signed-off-by: Benjamin Wang <wachao@vmware.com>
Only `net.TCPConn` supports `SetKeepAlive` and `SetKeepAlivePeriod` by default, so if you want to warp multiple layers of net.Listener, the `keepaliveListener` should be the one which is closest to the original `net.Listener` implementation, namely `TCPListener`. Also refer to etcd-io#14356 Signed-off-by: Benjamin Wang <wachao@vmware.com>
Two issues:
./etcd --socket-reuse-address --socket-reuse-port
, actually etcd setting the SetKeepAlive or SetKeepAlivePeriod fails, but the current code ignores the errors. This issue can happen on both Linux and Mac.Analysis and solution
Currently etcd defines an keepAliveConn interface, and the
limitListenerConn implements this interface.
The high level diagram/relationship is something like below (excluding the unix(s) and TLS for simplicity),
There are three issues:
SetKeepAlive
andSetKeepAlivePeriod
by default. So the customized conns (previously thelimitListenConn
, now thekeepAliveConn
) use golang's type assertion to convert thenet.Conn
tonet.TCPConn
, and it just leverage thenet.TCPConn
to set thekeepalive
andkeepalivePeriod
. If there are multiple layers of net.Listener encapsulations, then it must be the one which is closest to the originalnet.Listener
implementation, namelyTCPListener
. Otherwise, the type assertion fails. It's exactly the reason for the first issue above.limitListener
, which is the only one which implements the keepAliveConn interface. It's exactly the reason for the failure on Mac.limitListenConn
to supportSetKeepAlive
andSetKeepAlivePeriod
, because it should focus on the functionality (rate limit) it's designed to.Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.