Skip to content

Commit

Permalink
Increase maxIdleConnection limit in etcd client.
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-t committed Apr 28, 2015
1 parent 99fc906 commit 07400f9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/kube-apiserver/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
forked "github.com/GoogleCloudPlatform/kubernetes/third_party/forked/coreos/go-etcd/etcd"

"github.com/coreos/go-etcd/etcd"
"github.com/golang/glog"
Expand Down Expand Up @@ -192,7 +193,16 @@ func newEtcd(etcdConfigFile string, etcdServerList util.StringList, storageVersi
return helper, err
}
} else {
client = etcd.NewClient(etcdServerList)
etcdClient := etcd.NewClient(etcdServerList)
transport := &http.Transport{
Dial: forked.Dial,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
MaxIdleConnsPerHost: 500,
}
etcdClient.SetTransport(transport)
client = etcdClient
}

return master.NewEtcdHelper(client, storageVersion, pathPrefix)
Expand Down
32 changes: 32 additions & 0 deletions third_party/forked/coreos/go-etcd/etcd/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package etcd

import (
"errors"
"net"
"time"
)

// dial attempts to open a TCP connection to the provided address, explicitly
// enabling keep-alives with a one-second interval.
func Dial(network, addr string) (net.Conn, error) {
conn, err := net.DialTimeout(network, addr, time.Second)
if err != nil {
return nil, err
}

tcpConn, ok := conn.(*net.TCPConn)
if !ok {
return nil, errors.New("Failed type-assertion of net.Conn as *net.TCPConn")
}

// Keep TCP alive to check whether or not the remote machine is down
if err = tcpConn.SetKeepAlive(true); err != nil {
return nil, err
}

if err = tcpConn.SetKeepAlivePeriod(time.Second); err != nil {
return nil, err
}

return tcpConn, nil
}

0 comments on commit 07400f9

Please sign in to comment.