Skip to content
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

Added client keepalive arguments to the grpc-proxy #17366

Merged
merged 4 commits into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions server/etcdmain/grpc_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ var (
grpcProxyMetricsListenAddr string
grpcProxyEndpoints []string
grpcProxyEndpointsAutoSyncInterval time.Duration
grpcProxyDialKeepAliveTime time.Duration
grpcProxyDialKeepAliveTimeout time.Duration
grpcProxyPermitWithoutStream bool
grpcProxyDNSCluster string
grpcProxyDNSClusterServiceName string
grpcProxyInsecureDiscovery bool
Expand Down Expand Up @@ -138,6 +141,9 @@ func newGRPCProxyStartCommand() *cobra.Command {
cmd.Flags().BoolVar(&grpcProxyInsecureDiscovery, "insecure-discovery", false, "accept insecure SRV records")
cmd.Flags().StringSliceVar(&grpcProxyEndpoints, "endpoints", []string{"127.0.0.1:2379"}, "comma separated etcd cluster endpoints")
cmd.Flags().DurationVar(&grpcProxyEndpointsAutoSyncInterval, "endpoints-auto-sync-interval", 0, "etcd endpoints auto sync interval (disabled by default)")
cmd.Flags().DurationVar(&grpcProxyDialKeepAliveTime, "dial-keepalive-time", 0, "keepalive time for client(grpc-proxy) connections (default 0, disable).")
cmd.Flags().DurationVar(&grpcProxyDialKeepAliveTimeout, "dial-keepalive-timeout", embed.DefaultGRPCKeepAliveTimeout, "keepalive timeout for client(grpc-proxy) connections (default 20s).")
cmd.Flags().BoolVar(&grpcProxyPermitWithoutStream, "permit-without-stream", false, "Enable client(grpc-proxy) to send keepalive pings even with no active RPCs.")
cmd.Flags().StringVar(&grpcProxyAdvertiseClientURL, "advertise-client-url", "127.0.0.1:23790", "advertise address to register (must be reachable by client)")
cmd.Flags().StringVar(&grpcProxyResolverPrefix, "resolver-prefix", "", "prefix to use for registering proxy (must be shared with other grpc-proxy members)")
cmd.Flags().IntVar(&grpcProxyResolverTTL, "resolver-ttl", 0, "specify TTL, in seconds, when registering proxy endpoints")
Expand Down Expand Up @@ -361,6 +367,13 @@ func newClientCfg(lg *zap.Logger, eps []string) (*clientv3.Config, error) {
if grpcMaxCallRecvMsgSize > 0 {
cfg.MaxCallRecvMsgSize = grpcMaxCallRecvMsgSize
}
if grpcProxyDialKeepAliveTime > 0 {
cfg.DialKeepAliveTime = grpcProxyDialKeepAliveTime
}
if grpcProxyDialKeepAliveTimeout > 0 {
cfg.DialKeepAliveTimeout = grpcProxyDialKeepAliveTimeout
}
cfg.PermitWithoutStream = grpcProxyPermitWithoutStream

tls := newTLS(grpcProxyCA, grpcProxyCert, grpcProxyKey, true)
if tls == nil && grpcProxyInsecureSkipTLSVerify {
Expand Down
Loading