From 31ff8c6b9a08d1168502e423bdd3fdbe4f2f729b Mon Sep 17 00:00:00 2001 From: Ryan Phillips Date: Tue, 19 Dec 2017 10:04:23 -0600 Subject: [PATCH] etcd client: add keepalive --- .../pkg/storage/storagebackend/factory/etcd3.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go b/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go index a5ccbf2fdd49..48bba73110b0 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go @@ -17,6 +17,8 @@ limitations under the License. package factory import ( + "time" + "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/pkg/transport" "golang.org/x/net/context" @@ -27,6 +29,13 @@ import ( "k8s.io/apiserver/pkg/storage/value" ) +// The short keepalive timeout and interval have been chosen to aggressively +// detect a failed etcd server without introducing much overhead. +var ( + keepaliveTime = 30 * time.Second + keepaliveTimeout = 10 * time.Second +) + func newETCD3Storage(c storagebackend.Config) (storage.Interface, DestroyFunc, error) { tlsInfo := transport.TLSInfo{ CertFile: c.CertFile, @@ -43,8 +52,10 @@ func newETCD3Storage(c storagebackend.Config) (storage.Interface, DestroyFunc, e tlsConfig = nil } cfg := clientv3.Config{ - Endpoints: c.ServerList, - TLS: tlsConfig, + DialKeepAliveTime: keepaliveTime, + DialKeepAliveTimeout: keepaliveTimeout, + Endpoints: c.ServerList, + TLS: tlsConfig, } client, err := clientv3.New(cfg) if err != nil {