From f6f375109e6d825587d8dba5048ffd9ac104b848 Mon Sep 17 00:00:00 2001 From: "Sahdev P. Zala" Date: Tue, 2 Oct 2018 12:04:39 -0400 Subject: [PATCH] clientv3: let etcd client use all available keepalive ClientParams We should allow etcd client use all of the available keepalive client parameters as documented in this link, https://godoc.org/google.golang.org/grpc/keepalive#ClientParameters Currently in the etcd, by default PermitWithoutStream is set to false, and user has no way to override it. On the server side, we explicitely setting EnforcementPolicy PermitWithoutStream to false and don't provide option to override it to user but on the client side we should allow this option as provided by the grpc. --- CHANGELOG-3.4.md | 3 +++ clientv3/client.go | 5 +++-- clientv3/config.go | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index c82354fface..56b255e8122 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -385,6 +385,9 @@ Note: **v3.5 will deprecate `etcd --log-package-levels` flag for `capnslog`**; ` - Fix [lease keepalive interval updates when response queue is full](https://github.com/etcd-io/etcd/pull/9952). - If `<-chan *clientv3LeaseKeepAliveResponse` from `clientv3.Lease.KeepAlive` was never consumed or channel is full, client was [sending keepalive request every 500ms](https://github.com/etcd-io/etcd/issues/9911) instead of expected rate of every "TTL / 3" duration. - Change [snapshot file permissions](https://github.com/etcd-io/etcd/pull/9977): On Linux, the snapshot file changes from readable by all (mode 0644) to readable by the user only (mode 0600). +- Client may choose to send keepalive pings to server using [`PermitWithoutStream`](https://github.com/etcd-io/etcd/pull/10146). + - By setting `PermitWithoutStream` to true, client can send keepalive pings to server without any active streams(RPCs). In other words, it allows sending keepalive pings with unary or simple RPC calls. + - `PermitWithoutStream` is set to false by default. ### etcdctl v3 diff --git a/clientv3/client.go b/clientv3/client.go index 57af96c2aec..0a578307b45 100644 --- a/clientv3/client.go +++ b/clientv3/client.go @@ -233,8 +233,9 @@ func (c *Client) processCreds(scheme string) (creds *credentials.TransportCreden func (c *Client) dialSetupOpts(creds *credentials.TransportCredentials, dopts ...grpc.DialOption) (opts []grpc.DialOption, err error) { if c.cfg.DialKeepAliveTime > 0 { params := keepalive.ClientParameters{ - Time: c.cfg.DialKeepAliveTime, - Timeout: c.cfg.DialKeepAliveTimeout, + Time: c.cfg.DialKeepAliveTime, + Timeout: c.cfg.DialKeepAliveTimeout, + PermitWithoutStream: c.cfg.PermitWithoutStream, } opts = append(opts, grpc.WithKeepaliveParams(params)) } diff --git a/clientv3/config.go b/clientv3/config.go index 4cea369076e..bda60b8e703 100644 --- a/clientv3/config.go +++ b/clientv3/config.go @@ -78,6 +78,9 @@ type Config struct { // If nil, use the default logger. // TODO: configure gRPC logger LogConfig *zap.Config + + // PermitWithoutStream, if set true, client can send keepalive pings to server without any active streams(RPCs). + PermitWithoutStream bool `json:"permit-without-stream"` } // DefaultLogConfig is the default client logging configuration.