From 689c4789fc534ce7445bcf5b693c46f8e834e38a Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 6 Mar 2017 13:20:10 -0800 Subject: [PATCH 1/3] vendor: update glide Signed-off-by: Gyu-Ho Lee --- glide.lock | 21 +++++++++++---------- glide.yaml | 10 ++++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/glide.lock b/glide.lock index f31fd1b9..6cfc927b 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: fd49652adb4ec58cdca302dab916ff1d3bb80ccdf078dff45579becd0e75d613 -updated: 2017-02-22T19:06:28.732861827-08:00 +hash: 11e6bd98c99ecd78b59d905847f46dd54ff2306035536eaa0754c8c4868870ed +updated: 2017-03-06T13:03:02.042405087-08:00 imports: - name: bitbucket.org/zombiezen/gopdf version: 1c63dc69751bc45441c2ce1f56b631c55294b4d5 @@ -21,7 +21,7 @@ imports: - name: github.com/cheggaaa/pb version: d7e6ca3010b6f084d8056847f55d7f572f180678 - name: github.com/coreos/etcd - version: 86c9bf5c3f68707048e2cea63101e0d8d156331d + version: 317f3571ff9407c17ad6fd68877c4e673954d25a subpackages: - auth/authpb - client @@ -89,7 +89,7 @@ imports: - vg/vgpdf - vg/vgsvg - name: github.com/googleapis/gax-go - version: da06d194a00e19ce00d9011a13931c3f6f6887c7 + version: 8c5154c0fe5bf18cf649634d4c6df50897a32751 - name: github.com/grpc-ecosystem/grpc-gateway version: 84398b94e188ee336f307779b57b3aa91af7063c subpackages: @@ -98,18 +98,19 @@ imports: - utilities - name: github.com/gyuho/dataframe version: 73de2c550b1177c1640f3dacbbc1af00f913fedb -- name: github.com/gyuho/psn - version: 0a50f90209cfd81ef2a20cbf01679f118f31f0ad +- name: github.com/gyuho/linux-inspect + version: c8b6d38d52ab5870033a270870b39b91dea54649 subpackages: + - psn - schema - name: github.com/hashicorp/consul - version: 65b7ed462cc574d57dc6dcc9bca74676089f7fee + version: db4f40f6f05d6ab6712951ad4e5f045f8e9e1c9c subpackages: - api - name: github.com/hashicorp/go-cleanhttp version: 3573b8b52aa7b37b9358d966a898feb387f62437 - name: github.com/hashicorp/serf - version: 050c56d31a1ff2ebc50e3f4810fdff7e7563f6c8 + version: d787b2e8f72b5da48c43b84c2617234401084050 subpackages: - coordinate - name: github.com/inconshreveable/mousetrap @@ -138,7 +139,7 @@ imports: subpackages: - codec - name: golang.org/x/image - version: b952c941a68f1a00c1f8d855a12a8282d2f1b4f0 + version: e6cbe778da3cea914ea6436d0f99309605c3dfc4 subpackages: - draw - font @@ -180,7 +181,7 @@ imports: - storage/v1 - transport - name: google.golang.org/appengine - version: 3a452f9e00122ead39586d68ffdb9c6e1326af3c + version: 5403c08c6e8fb3b2dc1209d2d833d8e8ac8240de subpackages: - internal - internal/app_identity diff --git a/glide.yaml b/glide.yaml index 1b266ed5..358ec969 100644 --- a/glide.yaml +++ b/glide.yaml @@ -9,7 +9,7 @@ import: - package: github.com/cheggaaa/pb version: d7e6ca3010b6f084d8056847f55d7f572f180678 - package: github.com/coreos/etcd - version: 86c9bf5c3f68707048e2cea63101e0d8d156331d + version: 317f3571ff9407c17ad6fd68877c4e673954d25a subpackages: - auth/authpb - client @@ -55,10 +55,12 @@ import: - vg/vgsvg - package: github.com/gyuho/dataframe version: 73de2c550b1177c1640f3dacbbc1af00f913fedb -- package: github.com/gyuho/psn - version: 0a50f90209cfd81ef2a20cbf01679f118f31f0ad +- package: github.com/gyuho/linux-inspect + version: c8b6d38d52ab5870033a270870b39b91dea54649 + subpackages: + - psn - package: github.com/hashicorp/consul - version: 65b7ed462cc574d57dc6dcc9bca74676089f7fee + version: db4f40f6f05d6ab6712951ad4e5f045f8e9e1c9c subpackages: - api - package: github.com/samuel/go-zookeeper From 62aa9e7dde6b36efb07a1b44cb3721b8427d6f5a Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 6 Mar 2017 13:21:43 -0800 Subject: [PATCH 2/3] vendor: update all Signed-off-by: Gyu-Ho Lee --- agent/command.go | 2 +- agent/server.go | 2 +- agent/server_system_metrics.go | 2 +- control/command.go | 2 +- .../github.com/coreos/etcd/clientv3/client.go | 31 +++++-- vendor/github.com/googleapis/gax-go/header.go | 24 ++++++ .../gyuho/{psn => linux-inspect}/LICENSE | 0 .../{ => linux-inspect}/psn/df_etc_mtab.go | 0 .../gyuho/{ => linux-inspect}/psn/doc.go | 0 .../gyuho/{ => linux-inspect}/psn/filter.go | 0 .../psn/generated_linux.go | 0 .../{ => linux-inspect}/psn/list_ds_linux.go | 0 .../{ => linux-inspect}/psn/list_ns_linux.go | 0 .../{ => linux-inspect}/psn/list_ps_linux.go | 0 .../{ => linux-inspect}/psn/list_ss_linux.go | 0 .../gyuho/{ => linux-inspect}/psn/proc_csv.go | 0 .../{ => linux-inspect}/psn/proc_csv_add.go | 0 .../psn/proc_csv_binary_search.go | 0 .../psn/proc_csv_interpolate.go | 0 .../psn/proc_diskstat_linux.go | 0 .../{ => linux-inspect}/psn/proc_io_linux.go | 0 .../psn/proc_loadavg_linux.go | 0 .../psn/proc_net_dev_linux.go | 0 .../psn/proc_net_tcp_linux.go | 0 .../psn/proc_stat_linux.go | 2 +- .../psn/proc_status_linux.go | 0 .../psn/proc_uptime_linux.go | 0 .../gyuho/{ => linux-inspect}/psn/top.go | 0 .../psn/top_parse_output.go | 0 .../{ => linux-inspect}/psn/top_stream.go | 0 .../gyuho/{ => linux-inspect}/psn/util.go | 0 .../psn/util_net_ip_linux.go | 0 .../psn/util_proc_linux.go | 0 .../{psn => linux-inspect}/schema/schema.go | 0 .../{psn => linux-inspect}/schema/util.go | 0 .../hashicorp/consul/api/operator.go | 80 +++++++++++++++++++ vendor/golang.org/x/image/draw/go1_8.go | 2 +- vendor/golang.org/x/image/draw/go1_9.go | 2 +- 38 files changed, 134 insertions(+), 15 deletions(-) create mode 100644 vendor/github.com/googleapis/gax-go/header.go rename vendor/github.com/gyuho/{psn => linux-inspect}/LICENSE (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/df_etc_mtab.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/doc.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/filter.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/generated_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/list_ds_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/list_ns_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/list_ps_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/list_ss_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_csv.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_csv_add.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_csv_binary_search.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_csv_interpolate.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_diskstat_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_io_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_loadavg_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_net_dev_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_net_tcp_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_stat_linux.go (99%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_status_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/proc_uptime_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/top.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/top_parse_output.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/top_stream.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/util.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/util_net_ip_linux.go (100%) rename vendor/github.com/gyuho/{ => linux-inspect}/psn/util_proc_linux.go (100%) rename vendor/github.com/gyuho/{psn => linux-inspect}/schema/schema.go (100%) rename vendor/github.com/gyuho/{psn => linux-inspect}/schema/util.go (100%) diff --git a/agent/command.go b/agent/command.go index 9b815a1e..c1c4c89d 100644 --- a/agent/command.go +++ b/agent/command.go @@ -23,7 +23,7 @@ import ( "github.com/coreos/dbtester/pkg/ntp" "github.com/coreos/etcd/pkg/netutil" "github.com/coreos/pkg/capnslog" - "github.com/gyuho/psn" + "github.com/gyuho/linux-inspect/psn" "github.com/spf13/cobra" "google.golang.org/grpc" ) diff --git a/agent/server.go b/agent/server.go index 3d9b9b10..095174d1 100644 --- a/agent/server.go +++ b/agent/server.go @@ -25,7 +25,7 @@ import ( "github.com/coreos/dbtester/dbtesterpb" "github.com/coreos/dbtester/pkg/fileinspect" - "github.com/gyuho/psn" + "github.com/gyuho/linux-inspect/psn" "golang.org/x/net/context" ) diff --git a/agent/server_system_metrics.go b/agent/server_system_metrics.go index 4b372748..b344daf4 100644 --- a/agent/server_system_metrics.go +++ b/agent/server_system_metrics.go @@ -19,7 +19,7 @@ import ( "os" "time" - "github.com/gyuho/psn" + "github.com/gyuho/linux-inspect/psn" ) // startMetrics starts collecting metrics. diff --git a/control/command.go b/control/command.go index 5d28c2cf..90d1207c 100644 --- a/control/command.go +++ b/control/command.go @@ -25,7 +25,7 @@ import ( "github.com/coreos/dbtester/dbtesterpb" "github.com/coreos/dbtester/pkg/ntp" "github.com/coreos/etcd/pkg/netutil" - "github.com/gyuho/psn" + "github.com/gyuho/linux-inspect/psn" "github.com/spf13/cobra" ) diff --git a/vendor/github.com/coreos/etcd/clientv3/client.go b/vendor/github.com/coreos/etcd/clientv3/client.go index 7cfb0b0e..ace40b45 100644 --- a/vendor/github.com/coreos/etcd/clientv3/client.go +++ b/vendor/github.com/coreos/etcd/clientv3/client.go @@ -48,7 +48,9 @@ type Client struct { Auth Maintenance - conn *grpc.ClientConn + conn *grpc.ClientConn + dialerrc chan error + cfg Config creds *credentials.TransportCredentials balancer *simpleBalancer @@ -214,7 +216,14 @@ func (c *Client) dialSetupOpts(endpoint string, dopts ...grpc.DialOption) (opts default: } 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)) @@ -316,11 +325,12 @@ func newClient(cfg *Config) (*Client, error) { ctx, cancel := context.WithCancel(baseCtx) client := &Client{ - conn: nil, - cfg: *cfg, - creds: creds, - ctx: ctx, - cancel: cancel, + conn: nil, + dialerrc: make(chan error, 1), + cfg: *cfg, + creds: creds, + ctx: ctx, + cancel: cancel, } if cfg.Username != "" && cfg.Password != "" { client.Username = cfg.Username @@ -347,9 +357,14 @@ func newClient(cfg *Config) (*Client, error) { case <-waitc: } if !hasConn { + err := grpc.ErrClientConnTimeout + select { + case err = <-client.dialerrc: + default: + } client.cancel() conn.Close() - return nil, grpc.ErrClientConnTimeout + return nil, err } } diff --git a/vendor/github.com/googleapis/gax-go/header.go b/vendor/github.com/googleapis/gax-go/header.go new file mode 100644 index 00000000..d81455ec --- /dev/null +++ b/vendor/github.com/googleapis/gax-go/header.go @@ -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:] +} diff --git a/vendor/github.com/gyuho/psn/LICENSE b/vendor/github.com/gyuho/linux-inspect/LICENSE similarity index 100% rename from vendor/github.com/gyuho/psn/LICENSE rename to vendor/github.com/gyuho/linux-inspect/LICENSE diff --git a/vendor/github.com/gyuho/psn/df_etc_mtab.go b/vendor/github.com/gyuho/linux-inspect/psn/df_etc_mtab.go similarity index 100% rename from vendor/github.com/gyuho/psn/df_etc_mtab.go rename to vendor/github.com/gyuho/linux-inspect/psn/df_etc_mtab.go diff --git a/vendor/github.com/gyuho/psn/doc.go b/vendor/github.com/gyuho/linux-inspect/psn/doc.go similarity index 100% rename from vendor/github.com/gyuho/psn/doc.go rename to vendor/github.com/gyuho/linux-inspect/psn/doc.go diff --git a/vendor/github.com/gyuho/psn/filter.go b/vendor/github.com/gyuho/linux-inspect/psn/filter.go similarity index 100% rename from vendor/github.com/gyuho/psn/filter.go rename to vendor/github.com/gyuho/linux-inspect/psn/filter.go diff --git a/vendor/github.com/gyuho/psn/generated_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/generated_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/generated_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/generated_linux.go diff --git a/vendor/github.com/gyuho/psn/list_ds_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/list_ds_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/list_ds_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/list_ds_linux.go diff --git a/vendor/github.com/gyuho/psn/list_ns_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/list_ns_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/list_ns_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/list_ns_linux.go diff --git a/vendor/github.com/gyuho/psn/list_ps_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/list_ps_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/list_ps_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/list_ps_linux.go diff --git a/vendor/github.com/gyuho/psn/list_ss_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/list_ss_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/list_ss_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/list_ss_linux.go diff --git a/vendor/github.com/gyuho/psn/proc_csv.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_csv.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_csv.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_csv.go diff --git a/vendor/github.com/gyuho/psn/proc_csv_add.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_csv_add.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_csv_add.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_csv_add.go diff --git a/vendor/github.com/gyuho/psn/proc_csv_binary_search.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_csv_binary_search.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_csv_binary_search.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_csv_binary_search.go diff --git a/vendor/github.com/gyuho/psn/proc_csv_interpolate.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_csv_interpolate.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_csv_interpolate.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_csv_interpolate.go diff --git a/vendor/github.com/gyuho/psn/proc_diskstat_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_diskstat_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_diskstat_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_diskstat_linux.go diff --git a/vendor/github.com/gyuho/psn/proc_io_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_io_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_io_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_io_linux.go diff --git a/vendor/github.com/gyuho/psn/proc_loadavg_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_loadavg_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_loadavg_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_loadavg_linux.go diff --git a/vendor/github.com/gyuho/psn/proc_net_dev_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_net_dev_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_net_dev_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_net_dev_linux.go diff --git a/vendor/github.com/gyuho/psn/proc_net_tcp_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_net_tcp_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_net_tcp_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_net_tcp_linux.go diff --git a/vendor/github.com/gyuho/psn/proc_stat_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_stat_linux.go similarity index 99% rename from vendor/github.com/gyuho/psn/proc_stat_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_stat_linux.go index c24c7107..4c17cc93 100644 --- a/vendor/github.com/gyuho/psn/proc_stat_linux.go +++ b/vendor/github.com/gyuho/linux-inspect/psn/proc_stat_linux.go @@ -12,7 +12,7 @@ import ( "strings" "github.com/dustin/go-humanize" - "github.com/gyuho/psn/schema" + "github.com/gyuho/linux-inspect/schema" ) // GetProcStatByPID reads '/proc/$PID/stat' data. diff --git a/vendor/github.com/gyuho/psn/proc_status_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_status_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_status_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_status_linux.go diff --git a/vendor/github.com/gyuho/psn/proc_uptime_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/proc_uptime_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/proc_uptime_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/proc_uptime_linux.go diff --git a/vendor/github.com/gyuho/psn/top.go b/vendor/github.com/gyuho/linux-inspect/psn/top.go similarity index 100% rename from vendor/github.com/gyuho/psn/top.go rename to vendor/github.com/gyuho/linux-inspect/psn/top.go diff --git a/vendor/github.com/gyuho/psn/top_parse_output.go b/vendor/github.com/gyuho/linux-inspect/psn/top_parse_output.go similarity index 100% rename from vendor/github.com/gyuho/psn/top_parse_output.go rename to vendor/github.com/gyuho/linux-inspect/psn/top_parse_output.go diff --git a/vendor/github.com/gyuho/psn/top_stream.go b/vendor/github.com/gyuho/linux-inspect/psn/top_stream.go similarity index 100% rename from vendor/github.com/gyuho/psn/top_stream.go rename to vendor/github.com/gyuho/linux-inspect/psn/top_stream.go diff --git a/vendor/github.com/gyuho/psn/util.go b/vendor/github.com/gyuho/linux-inspect/psn/util.go similarity index 100% rename from vendor/github.com/gyuho/psn/util.go rename to vendor/github.com/gyuho/linux-inspect/psn/util.go diff --git a/vendor/github.com/gyuho/psn/util_net_ip_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/util_net_ip_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/util_net_ip_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/util_net_ip_linux.go diff --git a/vendor/github.com/gyuho/psn/util_proc_linux.go b/vendor/github.com/gyuho/linux-inspect/psn/util_proc_linux.go similarity index 100% rename from vendor/github.com/gyuho/psn/util_proc_linux.go rename to vendor/github.com/gyuho/linux-inspect/psn/util_proc_linux.go diff --git a/vendor/github.com/gyuho/psn/schema/schema.go b/vendor/github.com/gyuho/linux-inspect/schema/schema.go similarity index 100% rename from vendor/github.com/gyuho/psn/schema/schema.go rename to vendor/github.com/gyuho/linux-inspect/schema/schema.go diff --git a/vendor/github.com/gyuho/psn/schema/util.go b/vendor/github.com/gyuho/linux-inspect/schema/util.go similarity index 100% rename from vendor/github.com/gyuho/psn/schema/util.go rename to vendor/github.com/gyuho/linux-inspect/schema/util.go diff --git a/vendor/github.com/hashicorp/consul/api/operator.go b/vendor/github.com/hashicorp/consul/api/operator.go index a8d04a38..b7129cdd 100644 --- a/vendor/github.com/hashicorp/consul/api/operator.go +++ b/vendor/github.com/hashicorp/consul/api/operator.go @@ -1,5 +1,13 @@ package api +import ( + "bytes" + "fmt" + "io" + "strconv" + "strings" +) + // Operator can be used to perform low-level operator tasks for Consul. type Operator struct { c *Client @@ -63,6 +71,25 @@ type KeyringResponse struct { 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. func (op *Operator) RaftGetConfiguration(q *QueryOptions) (*RaftConfiguration, error) { 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() 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 +} diff --git a/vendor/golang.org/x/image/draw/go1_8.go b/vendor/golang.org/x/image/draw/go1_8.go index 95db46fb..ec192b71 100644 --- a/vendor/golang.org/x/image/draw/go1_8.go +++ b/vendor/golang.org/x/image/draw/go1_8.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !go1.9 +// +build !go1.9,!go1.8.typealias package draw diff --git a/vendor/golang.org/x/image/draw/go1_9.go b/vendor/golang.org/x/image/draw/go1_9.go index 1e878e1d..fc548e94 100644 --- a/vendor/golang.org/x/image/draw/go1_9.go +++ b/vendor/golang.org/x/image/draw/go1_9.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build go1.9 +// +build go1.9 go1.8.typealias package draw From 56f0558c0998e0b8ce89758bd7c06dfcb9e3779b Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 6 Mar 2017 13:22:17 -0800 Subject: [PATCH 3/3] README: update link Signed-off-by: Gyu-Ho Lee --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8765821..b3645757 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Distributed database benchmark tester: etcd, Zookeeper, Consul, zetcd, cetcd - Database Client - https://github.com/coreos/dbtester/tree/master/control - System Metrics - - https://github.com/gyuho/psn + - https://github.com/gyuho/linux-inspect - Test Data Analysis - https://github.com/coreos/dbtester/tree/master/analyze - https://github.com/gyuho/dataframe