mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Update go-etcd dependency
This commit is contained in:
parent
9df9fa7e78
commit
f659034da5
4
Godeps/Godeps.json
generated
4
Godeps/Godeps.json
generated
@ -108,8 +108,8 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/coreos/go-etcd/etcd",
|
||||
"Comment": "v2.0.0-13-g4cceaf7",
|
||||
"Rev": "4cceaf7283b76f27c4a732b20730dcdb61053bf5"
|
||||
"Comment": "v2.0.0-34-gde3514f",
|
||||
"Rev": "de3514f25635bbfb024fdaf2a8d5f67378492675"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/coreos/go-oidc/http",
|
||||
|
34
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/client.go
generated
vendored
34
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/client.go
generated
vendored
@ -192,7 +192,7 @@ func (c *Client) Close() {
|
||||
// initHTTPClient initializes a HTTP client for etcd client
|
||||
func (c *Client) initHTTPClient() {
|
||||
c.transport = &http.Transport{
|
||||
Dial: c.dial,
|
||||
Dial: c.DefaultDial,
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
@ -216,12 +216,12 @@ func (c *Client) initHTTPSClient(cert, key string) error {
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
|
||||
tr := &http.Transport{
|
||||
c.transport = &http.Transport{
|
||||
TLSClientConfig: tlsConfig,
|
||||
Dial: c.dial,
|
||||
Dial: c.DefaultDial,
|
||||
}
|
||||
|
||||
c.httpClient = &http.Client{Transport: tr}
|
||||
c.httpClient = &http.Client{Transport: c.transport}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -391,29 +391,15 @@ func (c *Client) createHttpPath(serverName string, _path string) string {
|
||||
return u.String()
|
||||
}
|
||||
|
||||
// dial attempts to open a TCP connection to the provided address, explicitly
|
||||
// DefaultDial attempts to open a TCP connection to the provided address, explicitly
|
||||
// enabling keep-alives with a one-second interval.
|
||||
func (c *Client) dial(network, addr string) (net.Conn, error) {
|
||||
conn, err := net.DialTimeout(network, addr, c.config.DialTimeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
func (c *Client) DefaultDial(network, addr string) (net.Conn, error) {
|
||||
dialer := net.Dialer{
|
||||
Timeout: c.config.DialTimeout,
|
||||
KeepAlive: time.Second,
|
||||
}
|
||||
|
||||
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
|
||||
return dialer.Dial(network, addr)
|
||||
}
|
||||
|
||||
func (c *Client) OpenCURL() {
|
||||
|
21
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/cluster.go
generated
vendored
21
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/cluster.go
generated
vendored
@ -3,12 +3,14 @@ package etcd
|
||||
import (
|
||||
"math/rand"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Cluster struct {
|
||||
Leader string `json:"leader"`
|
||||
Machines []string `json:"machines"`
|
||||
picked int
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func NewCluster(machines []string) *Cluster {
|
||||
@ -17,6 +19,8 @@ func NewCluster(machines []string) *Cluster {
|
||||
machines = []string{"http://127.0.0.1:4001"}
|
||||
}
|
||||
|
||||
machines = shuffleStringSlice(machines)
|
||||
logger.Debug("Shuffle cluster machines", machines)
|
||||
// default leader and machines
|
||||
return &Cluster{
|
||||
Leader: "",
|
||||
@ -25,13 +29,26 @@ func NewCluster(machines []string) *Cluster {
|
||||
}
|
||||
}
|
||||
|
||||
func (cl *Cluster) failure() { cl.picked = rand.Intn(len(cl.Machines)) }
|
||||
func (cl *Cluster) pick() string { return cl.Machines[cl.picked] }
|
||||
func (cl *Cluster) failure() {
|
||||
cl.mu.Lock()
|
||||
defer cl.mu.Unlock()
|
||||
cl.picked = (cl.picked + 1) % len(cl.Machines)
|
||||
}
|
||||
|
||||
func (cl *Cluster) pick() string {
|
||||
cl.mu.Lock()
|
||||
defer cl.mu.Unlock()
|
||||
return cl.Machines[cl.picked]
|
||||
}
|
||||
|
||||
func (cl *Cluster) updateFromStr(machines string) {
|
||||
cl.mu.Lock()
|
||||
defer cl.mu.Unlock()
|
||||
|
||||
cl.Machines = strings.Split(machines, ",")
|
||||
for i := range cl.Machines {
|
||||
cl.Machines[i] = strings.TrimSpace(cl.Machines[i])
|
||||
}
|
||||
cl.Machines = shuffleStringSlice(cl.Machines)
|
||||
cl.picked = rand.Intn(len(cl.Machines))
|
||||
}
|
||||
|
2
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/requests.go
generated
vendored
2
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/requests.go
generated
vendored
@ -348,7 +348,7 @@ func DefaultCheckRetry(cluster *Cluster, numReqs int, lastResp http.Response,
|
||||
}
|
||||
// sleep some time and expect leader election finish
|
||||
time.Sleep(time.Millisecond * 200)
|
||||
logger.Warning("bad response status code", lastResp.StatusCode)
|
||||
logger.Warning("bad response status code ", lastResp.StatusCode)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
1662
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/response.generated.go
generated
vendored
1662
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/response.generated.go
generated
vendored
File diff suppressed because it is too large
Load Diff
19
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/shuffle.go
generated
vendored
Normal file
19
Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/shuffle.go
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
package etcd
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func shuffleStringSlice(cards []string) []string {
|
||||
size := len(cards)
|
||||
//Do not need to copy if nothing changed
|
||||
if size <= 1 {
|
||||
return cards
|
||||
}
|
||||
shuffled := make([]string, size)
|
||||
index := rand.Perm(size)
|
||||
for i := range cards {
|
||||
shuffled[index[i]] = cards[i]
|
||||
}
|
||||
return shuffled
|
||||
}
|
Loading…
Reference in New Issue
Block a user