From 73c530de83548bbbac7c8cc7bf093e2260b81708 Mon Sep 17 00:00:00 2001 From: Lili Cosic Date: Wed, 19 May 2021 17:25:37 +0200 Subject: [PATCH] client,server: Expose reuse-port and reuse-address so they can be configured via a config file. --- client/pkg/transport/sockopt.go | 4 ++-- server/embed/config.go | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/pkg/transport/sockopt.go b/client/pkg/transport/sockopt.go index 38548ddd713..fe028c61323 100644 --- a/client/pkg/transport/sockopt.go +++ b/client/pkg/transport/sockopt.go @@ -21,12 +21,12 @@ type SocketOpts struct { // in which case lock on data file could result in unexpected // condition. User should take caution to protect against lock race. // [1] https://man7.org/linux/man-pages/man7/socket.7.html - ReusePort bool + ReusePort bool `json:"reuse-port"` // ReuseAddress enables a socket option SO_REUSEADDR which allows // binding to an address in `TIME_WAIT` state. Useful to improve MTTR // in cases where etcd slow to restart due to excessive `TIME_WAIT`. // [1] https://man7.org/linux/man-pages/man7/socket.7.html - ReuseAddress bool + ReuseAddress bool `json:"reuse-address"` } func getControls(sopts *SocketOpts) Controls { diff --git a/server/embed/config.go b/server/embed/config.go index 380c0c3aaa8..eec169a856d 100644 --- a/server/embed/config.go +++ b/server/embed/config.go @@ -252,7 +252,7 @@ type Config struct { GRPCKeepAliveTimeout time.Duration `json:"grpc-keepalive-timeout"` // SocketOpts are socket options passed to listener config. - SocketOpts transport.SocketOpts + SocketOpts transport.SocketOpts `json:"socket-options"` // PreVote is true to enable Raft Pre-Vote. // If enabled, Raft runs an additional election phase @@ -449,7 +449,10 @@ func NewConfig() *Config { GRPCKeepAliveInterval: DefaultGRPCKeepAliveInterval, GRPCKeepAliveTimeout: DefaultGRPCKeepAliveTimeout, - SocketOpts: transport.SocketOpts{}, + SocketOpts: transport.SocketOpts{ + ReusePort: false, + ReuseAddress: false, + }, TickMs: 100, ElectionMs: 1000,