Merge pull request #315 from gyuho/update

vendor: sync with etcd master, minor clean up
This commit is contained in:
Gyu-Ho Lee 2017-03-06 13:27:47 -08:00 committed by GitHub
commit 2008a31aa7
41 changed files with 152 additions and 30 deletions

View File

@ -11,7 +11,7 @@ Distributed database benchmark tester: etcd, Zookeeper, Consul, zetcd, cetcd
- Database Client - Database Client
- https://github.com/coreos/dbtester/tree/master/control - https://github.com/coreos/dbtester/tree/master/control
- System Metrics - System Metrics
- https://github.com/gyuho/psn - https://github.com/gyuho/linux-inspect
- Test Data Analysis - Test Data Analysis
- https://github.com/coreos/dbtester/tree/master/analyze - https://github.com/coreos/dbtester/tree/master/analyze
- https://github.com/gyuho/dataframe - https://github.com/gyuho/dataframe

View File

@ -23,7 +23,7 @@ import (
"github.com/coreos/dbtester/pkg/ntp" "github.com/coreos/dbtester/pkg/ntp"
"github.com/coreos/etcd/pkg/netutil" "github.com/coreos/etcd/pkg/netutil"
"github.com/coreos/pkg/capnslog" "github.com/coreos/pkg/capnslog"
"github.com/gyuho/psn" "github.com/gyuho/linux-inspect/psn"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"google.golang.org/grpc" "google.golang.org/grpc"
) )

View File

@ -25,7 +25,7 @@ import (
"github.com/coreos/dbtester/dbtesterpb" "github.com/coreos/dbtester/dbtesterpb"
"github.com/coreos/dbtester/pkg/fileinspect" "github.com/coreos/dbtester/pkg/fileinspect"
"github.com/gyuho/psn" "github.com/gyuho/linux-inspect/psn"
"golang.org/x/net/context" "golang.org/x/net/context"
) )

View File

@ -19,7 +19,7 @@ import (
"os" "os"
"time" "time"
"github.com/gyuho/psn" "github.com/gyuho/linux-inspect/psn"
) )
// startMetrics starts collecting metrics. // startMetrics starts collecting metrics.

View File

@ -25,7 +25,7 @@ import (
"github.com/coreos/dbtester/dbtesterpb" "github.com/coreos/dbtester/dbtesterpb"
"github.com/coreos/dbtester/pkg/ntp" "github.com/coreos/dbtester/pkg/ntp"
"github.com/coreos/etcd/pkg/netutil" "github.com/coreos/etcd/pkg/netutil"
"github.com/gyuho/psn" "github.com/gyuho/linux-inspect/psn"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )

21
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: fd49652adb4ec58cdca302dab916ff1d3bb80ccdf078dff45579becd0e75d613 hash: 11e6bd98c99ecd78b59d905847f46dd54ff2306035536eaa0754c8c4868870ed
updated: 2017-02-22T19:06:28.732861827-08:00 updated: 2017-03-06T13:03:02.042405087-08:00
imports: imports:
- name: bitbucket.org/zombiezen/gopdf - name: bitbucket.org/zombiezen/gopdf
version: 1c63dc69751bc45441c2ce1f56b631c55294b4d5 version: 1c63dc69751bc45441c2ce1f56b631c55294b4d5
@ -21,7 +21,7 @@ imports:
- name: github.com/cheggaaa/pb - name: github.com/cheggaaa/pb
version: d7e6ca3010b6f084d8056847f55d7f572f180678 version: d7e6ca3010b6f084d8056847f55d7f572f180678
- name: github.com/coreos/etcd - name: github.com/coreos/etcd
version: 86c9bf5c3f68707048e2cea63101e0d8d156331d version: 317f3571ff9407c17ad6fd68877c4e673954d25a
subpackages: subpackages:
- auth/authpb - auth/authpb
- client - client
@ -89,7 +89,7 @@ imports:
- vg/vgpdf - vg/vgpdf
- vg/vgsvg - vg/vgsvg
- name: github.com/googleapis/gax-go - name: github.com/googleapis/gax-go
version: da06d194a00e19ce00d9011a13931c3f6f6887c7 version: 8c5154c0fe5bf18cf649634d4c6df50897a32751
- name: github.com/grpc-ecosystem/grpc-gateway - name: github.com/grpc-ecosystem/grpc-gateway
version: 84398b94e188ee336f307779b57b3aa91af7063c version: 84398b94e188ee336f307779b57b3aa91af7063c
subpackages: subpackages:
@ -98,18 +98,19 @@ imports:
- utilities - utilities
- name: github.com/gyuho/dataframe - name: github.com/gyuho/dataframe
version: 73de2c550b1177c1640f3dacbbc1af00f913fedb version: 73de2c550b1177c1640f3dacbbc1af00f913fedb
- name: github.com/gyuho/psn - name: github.com/gyuho/linux-inspect
version: 0a50f90209cfd81ef2a20cbf01679f118f31f0ad version: c8b6d38d52ab5870033a270870b39b91dea54649
subpackages: subpackages:
- psn
- schema - schema
- name: github.com/hashicorp/consul - name: github.com/hashicorp/consul
version: 65b7ed462cc574d57dc6dcc9bca74676089f7fee version: db4f40f6f05d6ab6712951ad4e5f045f8e9e1c9c
subpackages: subpackages:
- api - api
- name: github.com/hashicorp/go-cleanhttp - name: github.com/hashicorp/go-cleanhttp
version: 3573b8b52aa7b37b9358d966a898feb387f62437 version: 3573b8b52aa7b37b9358d966a898feb387f62437
- name: github.com/hashicorp/serf - name: github.com/hashicorp/serf
version: 050c56d31a1ff2ebc50e3f4810fdff7e7563f6c8 version: d787b2e8f72b5da48c43b84c2617234401084050
subpackages: subpackages:
- coordinate - coordinate
- name: github.com/inconshreveable/mousetrap - name: github.com/inconshreveable/mousetrap
@ -138,7 +139,7 @@ imports:
subpackages: subpackages:
- codec - codec
- name: golang.org/x/image - name: golang.org/x/image
version: b952c941a68f1a00c1f8d855a12a8282d2f1b4f0 version: e6cbe778da3cea914ea6436d0f99309605c3dfc4
subpackages: subpackages:
- draw - draw
- font - font
@ -180,7 +181,7 @@ imports:
- storage/v1 - storage/v1
- transport - transport
- name: google.golang.org/appengine - name: google.golang.org/appengine
version: 3a452f9e00122ead39586d68ffdb9c6e1326af3c version: 5403c08c6e8fb3b2dc1209d2d833d8e8ac8240de
subpackages: subpackages:
- internal - internal
- internal/app_identity - internal/app_identity

View File

@ -9,7 +9,7 @@ import:
- package: github.com/cheggaaa/pb - package: github.com/cheggaaa/pb
version: d7e6ca3010b6f084d8056847f55d7f572f180678 version: d7e6ca3010b6f084d8056847f55d7f572f180678
- package: github.com/coreos/etcd - package: github.com/coreos/etcd
version: 86c9bf5c3f68707048e2cea63101e0d8d156331d version: 317f3571ff9407c17ad6fd68877c4e673954d25a
subpackages: subpackages:
- auth/authpb - auth/authpb
- client - client
@ -55,10 +55,12 @@ import:
- vg/vgsvg - vg/vgsvg
- package: github.com/gyuho/dataframe - package: github.com/gyuho/dataframe
version: 73de2c550b1177c1640f3dacbbc1af00f913fedb version: 73de2c550b1177c1640f3dacbbc1af00f913fedb
- package: github.com/gyuho/psn - package: github.com/gyuho/linux-inspect
version: 0a50f90209cfd81ef2a20cbf01679f118f31f0ad version: c8b6d38d52ab5870033a270870b39b91dea54649
subpackages:
- psn
- package: github.com/hashicorp/consul - package: github.com/hashicorp/consul
version: 65b7ed462cc574d57dc6dcc9bca74676089f7fee version: db4f40f6f05d6ab6712951ad4e5f045f8e9e1c9c
subpackages: subpackages:
- api - api
- package: github.com/samuel/go-zookeeper - package: github.com/samuel/go-zookeeper

View File

@ -48,7 +48,9 @@ type Client struct {
Auth Auth
Maintenance Maintenance
conn *grpc.ClientConn conn *grpc.ClientConn
dialerrc chan error
cfg Config cfg Config
creds *credentials.TransportCredentials creds *credentials.TransportCredentials
balancer *simpleBalancer balancer *simpleBalancer
@ -214,7 +216,14 @@ func (c *Client) dialSetupOpts(endpoint string, dopts ...grpc.DialOption) (opts
default: default:
} }
dialer := &net.Dialer{Timeout: t} dialer := &net.Dialer{Timeout: t}
return dialer.DialContext(c.ctx, proto, host) conn, err := dialer.DialContext(c.ctx, proto, host)
if err != nil {
select {
case c.dialerrc <- err:
default:
}
}
return conn, err
} }
opts = append(opts, grpc.WithDialer(f)) opts = append(opts, grpc.WithDialer(f))
@ -316,11 +325,12 @@ func newClient(cfg *Config) (*Client, error) {
ctx, cancel := context.WithCancel(baseCtx) ctx, cancel := context.WithCancel(baseCtx)
client := &Client{ client := &Client{
conn: nil, conn: nil,
cfg: *cfg, dialerrc: make(chan error, 1),
creds: creds, cfg: *cfg,
ctx: ctx, creds: creds,
cancel: cancel, ctx: ctx,
cancel: cancel,
} }
if cfg.Username != "" && cfg.Password != "" { if cfg.Username != "" && cfg.Password != "" {
client.Username = cfg.Username client.Username = cfg.Username
@ -347,9 +357,14 @@ func newClient(cfg *Config) (*Client, error) {
case <-waitc: case <-waitc:
} }
if !hasConn { if !hasConn {
err := grpc.ErrClientConnTimeout
select {
case err = <-client.dialerrc:
default:
}
client.cancel() client.cancel()
conn.Close() conn.Close()
return nil, grpc.ErrClientConnTimeout return nil, err
} }
} }

24
vendor/github.com/googleapis/gax-go/header.go generated vendored Normal file
View File

@ -0,0 +1,24 @@
package gax
import "bytes"
// XGoogHeader is for use by the Google Cloud Libraries only.
//
// XGoogHeader formats key-value pairs.
// The resulting string is suitable for x-goog-api-client header.
func XGoogHeader(keyval ...string) string {
if len(keyval) == 0 {
return ""
}
if len(keyval)%2 != 0 {
panic("gax.Header: odd argument count")
}
var buf bytes.Buffer
for i := 0; i < len(keyval); i += 2 {
buf.WriteByte(' ')
buf.WriteString(keyval[i])
buf.WriteByte('/')
buf.WriteString(keyval[i+1])
}
return buf.String()[1:]
}

View File

@ -12,7 +12,7 @@ import (
"strings" "strings"
"github.com/dustin/go-humanize" "github.com/dustin/go-humanize"
"github.com/gyuho/psn/schema" "github.com/gyuho/linux-inspect/schema"
) )
// GetProcStatByPID reads '/proc/$PID/stat' data. // GetProcStatByPID reads '/proc/$PID/stat' data.

View File

@ -1,5 +1,13 @@
package api package api
import (
"bytes"
"fmt"
"io"
"strconv"
"strings"
)
// Operator can be used to perform low-level operator tasks for Consul. // Operator can be used to perform low-level operator tasks for Consul.
type Operator struct { type Operator struct {
c *Client c *Client
@ -63,6 +71,25 @@ type KeyringResponse struct {
NumNodes int NumNodes int
} }
// AutopilotConfiguration is used for querying/setting the Autopilot configuration.
// Autopilot helps manage operator tasks related to Consul servers like removing
// failed servers from the Raft quorum.
type AutopilotConfiguration struct {
// CleanupDeadServers controls whether to remove dead servers from the Raft
// peer list when a new server joins
CleanupDeadServers bool
// CreateIndex holds the index corresponding the creation of this configuration.
// This is a read-only field.
CreateIndex uint64
// ModifyIndex will be set to the index of the last update when retrieving the
// Autopilot configuration. Resubmitting a configuration with
// AutopilotCASConfiguration will perform a check-and-set operation which ensures
// there hasn't been a subsequent update since the configuration was retrieved.
ModifyIndex uint64
}
// RaftGetConfiguration is used to query the current Raft peer set. // RaftGetConfiguration is used to query the current Raft peer set.
func (op *Operator) RaftGetConfiguration(q *QueryOptions) (*RaftConfiguration, error) { func (op *Operator) RaftGetConfiguration(q *QueryOptions) (*RaftConfiguration, error) {
r := op.c.newRequest("GET", "/v1/operator/raft/configuration") r := op.c.newRequest("GET", "/v1/operator/raft/configuration")
@ -161,3 +188,56 @@ func (op *Operator) KeyringUse(key string, q *WriteOptions) error {
resp.Body.Close() resp.Body.Close()
return nil return nil
} }
// AutopilotGetConfiguration is used to query the current Autopilot configuration.
func (op *Operator) AutopilotGetConfiguration(q *QueryOptions) (*AutopilotConfiguration, error) {
r := op.c.newRequest("GET", "/v1/operator/autopilot/configuration")
r.setQueryOptions(q)
_, resp, err := requireOK(op.c.doRequest(r))
if err != nil {
return nil, err
}
defer resp.Body.Close()
var out AutopilotConfiguration
if err := decodeBody(resp, &out); err != nil {
return nil, err
}
return &out, nil
}
// AutopilotSetConfiguration is used to set the current Autopilot configuration.
func (op *Operator) AutopilotSetConfiguration(conf *AutopilotConfiguration, q *WriteOptions) error {
r := op.c.newRequest("PUT", "/v1/operator/autopilot/configuration")
r.setWriteOptions(q)
r.obj = conf
_, resp, err := requireOK(op.c.doRequest(r))
if err != nil {
return err
}
resp.Body.Close()
return nil
}
// AutopilotCASConfiguration is used to perform a Check-And-Set update on the
// Autopilot configuration. The ModifyIndex value will be respected. Returns
// true on success or false on failures.
func (op *Operator) AutopilotCASConfiguration(conf *AutopilotConfiguration, q *WriteOptions) (bool, error) {
r := op.c.newRequest("PUT", "/v1/operator/autopilot/configuration")
r.setWriteOptions(q)
r.params.Set("cas", strconv.FormatUint(conf.ModifyIndex, 10))
r.obj = conf
_, resp, err := requireOK(op.c.doRequest(r))
if err != nil {
return false, err
}
defer resp.Body.Close()
var buf bytes.Buffer
if _, err := io.Copy(&buf, resp.Body); err != nil {
return false, fmt.Errorf("Failed to read response: %v", err)
}
res := strings.Contains(string(buf.Bytes()), "true")
return res, nil
}

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build !go1.9 // +build !go1.9,!go1.8.typealias
package draw package draw

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build go1.9 // +build go1.9 go1.8.typealias
package draw package draw