Skip to content

Commit

Permalink
etcd client: add keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Phillips committed Jan 9, 2018
1 parent ea2fbd4 commit 31ff8c6
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 31ff8c6

Please sign in to comment.