From d3a71c5ba81673d7f80e90766ebb350ff89e5dd2 Mon Sep 17 00:00:00 2001 From: Andy Bursavich Date: Thu, 6 Jun 2019 08:05:31 -0700 Subject: [PATCH 1/2] thanos: upgrade dependency and default to v0.5.0 --- example/thanos/prometheus.yaml | 2 +- example/thanos/query-deployment.yaml | 2 +- go.mod | 2 +- pkg/prometheus/statefulset.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/thanos/prometheus.yaml b/example/thanos/prometheus.yaml index 621f93c35d..07717a68eb 100644 --- a/example/thanos/prometheus.yaml +++ b/example/thanos/prometheus.yaml @@ -14,4 +14,4 @@ spec: role: prometheus-rulefiles prometheus: k8s thanos: - version: v0.4.0 + version: v0.5.0 diff --git a/example/thanos/query-deployment.yaml b/example/thanos/query-deployment.yaml index 416c98ba46..7fc25fb408 100644 --- a/example/thanos/query-deployment.yaml +++ b/example/thanos/query-deployment.yaml @@ -16,7 +16,7 @@ spec: spec: containers: - name: thanos-query - image: improbable/thanos:v0.4.0 + image: improbable/thanos:v0.5.0 args: - query - --log.level=debug diff --git a/go.mod b/go.mod index 57f2833230..6930f55a1d 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/googleapis/gnostic v0.1.0 // indirect github.com/hashicorp/go-version v1.1.0 github.com/imdario/mergo v0.3.5 // indirect - github.com/improbable-eng/thanos v0.4.0 + github.com/improbable-eng/thanos v0.5.0 github.com/jsonnet-bundler/jsonnet-bundler v0.1.0 github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452 diff --git a/pkg/prometheus/statefulset.go b/pkg/prometheus/statefulset.go index 83dd19847a..d0e742ba17 100644 --- a/pkg/prometheus/statefulset.go +++ b/pkg/prometheus/statefulset.go @@ -35,7 +35,7 @@ import ( const ( governingServiceName = "prometheus-operated" DefaultPrometheusVersion = "v2.7.1" - DefaultThanosVersion = "v0.4.0" + DefaultThanosVersion = "v0.5.0" defaultRetention = "24h" defaultReplicaExternalLabelName = "prometheus_replica" storageDir = "/prometheus" From 1905a5220e28926511616f00d7fd49799113fa42 Mon Sep 17 00:00:00 2001 From: Andy Bursavich Date: Thu, 6 Jun 2019 08:05:57 -0700 Subject: [PATCH 2/2] thanos: go mod tidy && go mod vendor --- go.mod | 9 +- go.sum | 227 +++++++----- .../golang/protobuf/proto/decode.go | 1 - .../golang/protobuf/proto/deprecated.go | 63 ++++ .../github.com/golang/protobuf/proto/equal.go | 3 +- .../golang/protobuf/proto/extensions.go | 78 +++- .../github.com/golang/protobuf/proto/lib.go | 38 +- .../golang/protobuf/proto/message_set.go | 137 +------ .../golang/protobuf/proto/pointer_reflect.go | 5 +- .../golang/protobuf/proto/pointer_unsafe.go | 15 +- .../golang/protobuf/proto/properties.go | 31 +- .../golang/protobuf/proto/table_marshal.go | 45 ++- .../golang/protobuf/proto/table_unmarshal.go | 72 ++-- .../golang/protobuf/ptypes/any/any.pb.go | 45 ++- .../golang/protobuf/ptypes/any/any.proto | 21 +- .../golang/protobuf/ptypes/duration.go | 2 +- .../protobuf/ptypes/duration/duration.pb.go | 26 +- .../golang/protobuf/ptypes/timestamp.go | 6 +- .../protobuf/ptypes/timestamp/timestamp.pb.go | 34 +- .../protobuf/ptypes/timestamp/timestamp.proto | 8 +- .../thanos/pkg/runutil/runutil.go | 4 +- .../client_golang/prometheus/collector.go | 2 +- .../client_golang/prometheus/doc.go | 6 +- .../client_golang/prometheus/histogram.go | 4 +- .../client_golang/prometheus/http.go | 1 - .../prometheus/promhttp/delegator.go | 1 - .../client_golang/prometheus/promhttp/http.go | 1 - .../client_golang/prometheus/registry.go | 2 +- .../client_golang/prometheus/summary.go | 151 +++++++- .../prometheus/common/expfmt/text_create.go | 12 +- .../bitbucket.org/ww/goautoneg/autoneg.go | 6 +- .../prometheus/common/model/metric.go | 1 - .../prometheus/procfs/MAINTAINERS.md | 3 +- .../github.com/prometheus/procfs/xfs/parse.go | 18 +- .../prometheus/pkg/labels/labels.go | 17 + .../prometheus/pkg/rulefmt/rulefmt.go | 8 +- .../pkg/textparse/openmetricslex.l.go | 4 +- .../pkg/textparse/openmetricsparse.go | 16 +- .../prometheus/pkg/textparse/promlex.l.go | 4 +- .../prometheus/pkg/textparse/promparse.go | 18 +- .../prometheus/prometheus/promql/ast.go | 5 +- .../prometheus/prometheus/promql/engine.go | 155 ++++---- .../prometheus/prometheus/promql/functions.go | 15 +- .../prometheus/prometheus/promql/lex.go | 348 +++++++++--------- .../prometheus/prometheus/promql/parse.go | 191 +++++----- .../prometheus/prometheus/promql/test.go | 30 +- .../prometheus/prometheus/promql/value.go | 8 +- .../prometheus/template/template.go | 18 +- .../github.com/prometheus/tsdb/.golangci.yml | 5 + vendor/github.com/prometheus/tsdb/.travis.yml | 2 - .../github.com/prometheus/tsdb/CHANGELOG.md | 32 +- vendor/github.com/prometheus/tsdb/Makefile | 5 - .../prometheus/tsdb/Makefile.common | 90 +++-- vendor/github.com/prometheus/tsdb/README.md | 3 +- vendor/github.com/prometheus/tsdb/block.go | 34 +- .../github.com/prometheus/tsdb/checkpoint.go | 3 +- .../prometheus/tsdb/chunkenc/chunk.go | 24 +- .../prometheus/tsdb/chunks/chunks.go | 54 +-- vendor/github.com/prometheus/tsdb/compact.go | 50 +-- vendor/github.com/prometheus/tsdb/db.go | 88 ++--- .../prometheus/tsdb/encoding/encoding.go | 8 +- .../prometheus/tsdb/errors/errors.go | 62 ++++ .../prometheus/tsdb/fileutil/fileutil.go | 4 +- .../prometheus/tsdb/fileutil/sync.go | 5 - .../prometheus/tsdb/fileutil/sync_darwin.go | 15 +- .../prometheus/tsdb/fileutil/sync_linux.go | 5 - vendor/github.com/prometheus/tsdb/go.mod | 2 +- .../prometheus/tsdb/goversion/goversion.go | 19 + .../prometheus/tsdb/goversion/init.go | 17 + vendor/github.com/prometheus/tsdb/head.go | 60 ++- .../github.com/prometheus/tsdb/index/index.go | 16 +- .../prometheus/tsdb/index/postings.go | 103 +++--- .../prometheus/tsdb/labels/labels.go | 29 +- .../prometheus/tsdb/labels/selector.go | 28 +- vendor/github.com/prometheus/tsdb/querier.go | 114 ++++-- vendor/github.com/prometheus/tsdb/repair.go | 30 +- .../github.com/prometheus/tsdb/tombstones.go | 21 +- vendor/github.com/prometheus/tsdb/wal.go | 8 +- vendor/github.com/prometheus/tsdb/wal/wal.go | 38 +- vendor/golang.org/x/net/http2/transport.go | 11 +- vendor/gopkg.in/inf.v0/dec.go | 2 +- vendor/modules.txt | 26 +- 82 files changed, 1741 insertions(+), 1187 deletions(-) create mode 100644 vendor/github.com/golang/protobuf/proto/deprecated.go create mode 100644 vendor/github.com/prometheus/tsdb/.golangci.yml create mode 100644 vendor/github.com/prometheus/tsdb/errors/errors.go create mode 100644 vendor/github.com/prometheus/tsdb/goversion/goversion.go create mode 100644 vendor/github.com/prometheus/tsdb/goversion/init.go diff --git a/go.mod b/go.mod index 6930f55a1d..8b97b561e5 100644 --- a/go.mod +++ b/go.mod @@ -14,8 +14,7 @@ require ( github.com/go-openapi/jsonreference v0.19.0 // indirect github.com/go-openapi/spec v0.17.2 github.com/go-openapi/swag v0.17.2 // indirect - github.com/gogo/protobuf v1.2.1 // indirect - github.com/golang/protobuf v1.2.0 + github.com/golang/protobuf v1.3.1 github.com/googleapis/gnostic v0.1.0 // indirect github.com/hashicorp/go-version v1.1.0 github.com/imdario/mergo v0.3.5 // indirect @@ -25,11 +24,9 @@ require ( github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452 github.com/oklog/run v1.0.0 github.com/pkg/errors v0.8.1 - github.com/prometheus/client_golang v0.9.2 - github.com/prometheus/prometheus v0.0.0-20190328180107-4d60eb36dcbe + github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 + github.com/prometheus/prometheus v2.9.2+incompatible github.com/stretchr/testify v1.3.0 - golang.org/x/crypto v0.0.0-20190424203555-c05e17bb3b2d // indirect - golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6 // indirect golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a // indirect golang.org/x/sync v0.0.0-20190423024810-112230192c58 golang.org/x/sys v0.0.0-20190425145619-16072639606e // indirect diff --git a/go.sum b/go.sum index f9cabe0478..49f95a9141 100644 --- a/go.sum +++ b/go.sum @@ -1,31 +1,39 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -contrib.go.opencensus.io/exporter/ocagent v0.4.1/go.mod h1:b6YwD5Q3Yvj4yk0CDK5vGXexygNzI09aXUdDEakQBgA= -git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -git.apache.org/thrift.git v0.0.0-20181218151757-9b75e4fe745a/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= +contrib.go.opencensus.io/exporter/ocagent v0.4.12/go.mod h1:450APlNTSR6FrvC3CTRqYosuDstRB9un7SOx2k/9ckA= github.com/Azure/azure-pipeline-go v0.1.8/go.mod h1:XA1kFWRVhSK+KNFiOhfv83Fv8L9achrP7OxIzeTn1Yg= github.com/Azure/azure-sdk-for-go v23.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-storage-blob-go v0.0.0-20181022225951-5152f14ace1c/go.mod h1:oGfmITT1V6x//CswqY2gtAHND+xIP64/qL7a5QJix0Y= github.com/Azure/go-autorest v11.2.8+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/OneOfOne/xxhash v1.2.5 h1:zl/OfRA6nftbBK9qTohYBJ5xvw6C/oNKizR7cZGl3cI= +github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= +github.com/a8m/mark v0.1.1-0.20170507133748-44f2db618845/go.mod h1:c8Mh99Cw82nrsAnPgxQSZHkswVOJF7/MqZb1ZdvriLM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/ant31/crd-validation v0.0.0-20180702145049-30f8a35d0ac2 h1:CDDf61yprxfS7bmBPyhH8pxaobD2VbO3d7laAxJbZos= github.com/ant31/crd-validation v0.0.0-20180702145049-30f8a35d0ac2/go.mod h1:X0noFIik9YqfhGYBLEHg8LJKEwy7QIitLQuFMpKLcPk= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aws/aws-sdk-go v0.0.0-20180507225419-00862f899353/go.mod h1:ZRmQr0FajVIyZ4ZzBYKG5P3ZqPz9IHG41ZoMu1ADI3k= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/biogo/store v0.0.0-20160505134755-913427a1d5e8/go.mod h1:Iev9Q3MErcn+w3UOJD/DkEzllvugfdx7bGcMOFhvr/4= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= @@ -34,7 +42,7 @@ github.com/brancz/gojsontoyaml v0.0.0-20190425155809-e8bd32d46b3d/go.mod h1:IyUJ github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= github.com/cenk/backoff v2.0.0+incompatible/go.mod h1:7FtoeaSnHoZnmZzz47cM35Y9nSW7tNyaidugnHTaFDE= -github.com/census-instrumentation/opencensus-proto v0.1.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/certifi/gocertifi v0.0.0-20180905225744-ee1a9a0726d2/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -44,13 +52,16 @@ github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292/go.mod h1:qRiX68m github.com/cockroachdb/cockroach v0.0.0-20170608034007-84bc9597164f/go.mod h1:xeT/CQ0qZHangbYbWShlCGAx31aV4AjGswDUjhKS6HQ= github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/etcd v3.3.12+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v0.0.0-20161101193935-9ed569b5d1ac/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/elastic/gosigar v0.9.0/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyCIo22xvs= github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/emicklei/go-restful v2.6.0+incompatible h1:luAX89wpjId5gV+GJV11MFD56GpAJTG2eUqCeDDgB98= @@ -61,11 +72,12 @@ github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a/go.mod h1:7Ga40eg github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/structtag v1.0.0/go.mod h1:IKitwq45uXL/yqi5mYghiD3w9H6eTOvI9vnk8tXMphA= -github.com/fortytw2/leaktest v1.2.0 h1:cj6GCiwJDH7l3tMHLjZDo0QqPtrXJiWSI9JgpeQKw+Q= -github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/getsentry/raven-go v0.1.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= +github.com/gernest/wow v0.1.0/go.mod h1:dEPabJRi5BneI1Nev1VWo0ZlcTWibHWp43qxKms4elY= +github.com/getsentry/raven-go v0.1.2/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-ini/ini v1.21.1/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= @@ -75,7 +87,7 @@ github.com/go-logfmt/logfmt v0.3.0 h1:8HUsc87TaSWLKwrnumgC8/YconD2fJQsRJAsWaPg2i github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.0 h1:FTUMcX77w5rQkClIzDtTxvn6Bsa894CcrzNj2MMfeg8= @@ -90,7 +102,7 @@ github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi88 github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.17.2 h1:K/ycE/XTUDFltNHSO32cGRUhrVGJD64o8WgAIZNyc3k= github.com/go-openapi/swag v0.17.2/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -100,14 +112,14 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20180924190550-6f2cf27854a4 h1:6UVLWz0fIIrv0UVj6t0A7cL48n8IyAdLVQqAYzEfsKI= github.com/golang/groupcache v0.0.0-20180924190550-6f2cf27854a4/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/snappy v0.0.0-20160529050041-d9eb7a3d35ec/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180124185431-e89373fe6b4a/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v0.0.0-20150304233714-bbcb9da2d746 h1:M6d2zDTA4cKXT6OwFsJxlo5tWrAukj3KfvJ1zcBatnA= @@ -118,40 +130,45 @@ github.com/googleapis/gax-go v2.0.2+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk github.com/googleapis/gnostic v0.0.0-20180520015035-48a0ecefe2e4/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/googleapis/gnostic v0.1.0 h1:rVsPeBmXbYv4If/cumu1AzZPwV58q433hvONV1UEZoI= github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/gophercloud/gophercloud v0.0.0-20181206160319-9d88c34913a9/go.mod h1:3WdhXV3rUYy9p6AUW8d94kr+HS62Y4VL9mBnFxsD8q4= +github.com/gophercloud/gophercloud v0.0.0-20190301152420-fca40860790e/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20181025070259-68e3a13e4117/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= -github.com/grpc-ecosystem/grpc-gateway v1.6.2/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= -github.com/grpc-ecosystem/grpc-gateway v1.6.3/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= +github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= -github.com/hashicorp/consul v0.0.0-20180615161029-bed22a81e9fd/go.mod h1:mFrjN1mfidgJfYP1xrJCF+AfRhr6Eaqhb2+sfyn/OOI= +github.com/hashicorp/consul v1.4.4/go.mod h1:mFrjN1mfidgJfYP1xrJCF+AfRhr6Eaqhb2+sfyn/OOI= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.0.0-20160407174126-ad28ea4487f0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.0.0-20150518234257-fa3f63826f7c/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90/go.mod h1:o4zcYY1e0GEZI6eSEr+43QDYmuGglw1qSO6qdHUHCgg= -github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/memberlist v0.1.0/go.mod h1:ncdBp14cuox2iFOq3kDiquKU6fqsTBc3W6JvZwjxxsE= -github.com/hashicorp/serf v0.0.0-20161007004122-1d4fa605f6ff/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE= -github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/improbable-eng/thanos v0.4.0 h1:mIk6Pw0EPFLWW++zc9PFulvjdfZwQTqlTvbcO1JorCk= -github.com/improbable-eng/thanos v0.4.0/go.mod h1:CYPZY0EwGQ4TTD4Y8Fh26yB923dGCoxslu70LAF2yWE= +github.com/improbable-eng/thanos v0.5.0 h1:tj9T9yskMeEJu1zy4DjmNHmu1JQ2WiFTo4mAjisrYHg= +github.com/improbable-eng/thanos v0.5.0/go.mod h1:RXlsWB7YlTbhIod//QDyd5cBZsnEN0jROXZJY/ol4nk= github.com/influxdata/influxdb v0.0.0-20170331210902-15e594fc09f1/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= github.com/jackc/pgx v3.2.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= @@ -161,11 +178,12 @@ github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBv github.com/jsonnet-bundler/jsonnet-bundler v0.1.0 h1:T/HtHFr+mYCRULrH1x/RnoB0prIs0rMkolJhFMXNC9A= github.com/jsonnet-bundler/jsonnet-bundler v0.1.0/go.mod h1:YKsSFc9VFhhLITkJS3X2PrRqWG9u2Jq99udTdDjQLfM= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v0.0.0-20150905172533-109e267447e9/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.1.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knz/strtime v0.0.0-20181018220328-af2256ee352c/go.mod h1:4ZxfWkxwtc7dBeifERVVWRy9F9rTU9p0yCDgeCtlius= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -175,6 +193,7 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= +github.com/leanovate/gopter v0.2.4/go.mod h1:gNcbPWNEWRe4lm+bycKqxUYoH5uoVje5SkOJ3uoLer8= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lightstep/lightstep-tracer-go v0.15.6/go.mod h1:6AMpwZpsyCFwSovxzM78e+AsYxE8sGwiM6C3TytaWeI= github.com/lovoo/gcloud-opentracing v0.3.0/go.mod h1:ZFqk2y38kMDDikZPAK7ynTTGuyt17nSPdS3K5e+ZTBY= @@ -182,25 +201,34 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3 github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.6 h1:SrwhHcpV4nWrMGdNcC2kXpMfcBVYGDuTArqyhocJgvA= github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.1.4/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/minio/minio-go v0.0.0-20190131015406-c8a261de75c1/go.mod h1:vuvdOZLJuf5HmJAJrKV64MmozrSsk+or0PB5dzdfspg= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/miekg/dns v1.1.8/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/minio/cli v1.20.0/go.mod h1:bYxnK0uS629N3Bq+AOZZ+6lwF77Sodk4+UL9vNuXhOY= +github.com/minio/minio-go/v6 v6.0.27-0.20190529152532-de69c0e465ed/go.mod h1:vaNT59cWULS37E+E9zkuN/BVnKHyXtVGS+b04Boc66Y= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v0.0.0-20180523094522-3864e76763d9/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452 h1:hOY53G+kBFhbYFpRVxHl5eS7laP6B1+Cq+Z9Dry1iMU= github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/montanaflynn/stats v0.0.0-20180911141734-db72e6cae808/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/mozillazg/go-cos v0.11.0/go.mod h1:Zp6DvvXn0RUOXGJ2chmWt2bLEqRAnJnS3DnAZsJsoaE= +github.com/mozillazg/go-cos v0.12.0/go.mod h1:Zp6DvvXn0RUOXGJ2chmWt2bLEqRAnJnS3DnAZsJsoaE= github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/oklog v0.0.0-20170918173356-f857583a70c3/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= @@ -208,52 +236,56 @@ github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.0-20180912035003-be2c049b30cc/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.4.1 h1:PZSj/UFNaVp3KxrzHOcS7oyuWA7LoOY/77yCTEFu21U= -github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opentracing-contrib/go-stdlib v0.0.0-20170113013457-1de4cc2120e7/go.mod h1:PLldrQSroqzH70Xl+1DQcGnefIbqsKR7UDaiux3zV+w= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.1/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= -github.com/openzipkin/zipkin-go v0.1.3/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/peterbourgon/diskv v0.0.0-20180312054125-0646ccaebea1/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/peterbourgon/g2s v0.0.0-20170223122336-d4e7ad98afea/go.mod h1:1VcHEd3ro4QMoHfiNl/j7Jkln9+KQuorp0PItHMJYNg= github.com/petermattis/goid v0.0.0-20170504144140-0ded85884ba5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1 h1:K47Rk0v/fkEfwfQet2KWhscE0cJzjgCCDBG2KHZoVno= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= -github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 h1:D+CiwcpGTW6pL6bv6KI3KbyEyCKyS+1JWS2h8PNDnGA= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f h1:BVwpUVJDADN2ufcGik7W992pyps0wZ888b/y9GXcLTU= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181119215939-b36ad289a3ea/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181218105931-67670fe90761 h1:z6tvbDJ5OLJ48FFmnksv04a78maSTRBUIhkdHYV5Y98= -github.com/prometheus/common v0.0.0-20181218105931-67670fe90761/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.3.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.0 h1:7etb9YClo3a6HjLzfl6rIQaU+FDfi0VSX39io3aQ+DM= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/prometheus v0.0.0-20190328180107-4d60eb36dcbe h1:Wpwxfdtx0+/3dgqBvUAB2CTRtHRimQrH4RTEJ5yxCUo= -github.com/prometheus/prometheus v0.0.0-20190328180107-4d60eb36dcbe/go.mod h1:mVHnNN4pf1p9fM7dRvZQAKj0Ex93s+mIhtsml8SJy5E= -github.com/prometheus/tsdb v0.6.1 h1:wUp5iY/rmwv6VNzZg4yaUVpkSs4nX5O5+aoviWTNeUo= -github.com/prometheus/tsdb v0.6.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 h1:/K3IL0Z1quvmJ7X0A1AwNEK7CRkVK3YwfOU/QAL4WGg= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/prometheus v2.9.2+incompatible h1:5QVnXpkSsbbG59TyZ99clRfaHQy2QuIlTv6dEgS66C4= +github.com/prometheus/prometheus v2.9.2+incompatible/go.mod h1:vdLuLLM0uqhLSofrQ7Nev2b/rQUyZ+pkT3zF7LB/i1g= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/prometheus/tsdb v0.8.0 h1:w1tAGxsBMLkuGrFMhqgcCeBkM5d1YI24udArs+aASuQ= +github.com/prometheus/tsdb v0.8.0/go.mod h1:fSI0j+IUQrDd7+ZtR9WKIGtoYAYAJUKcKhYLG25tN4g= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rlmcpherson/s3gof3r v0.5.0/go.mod h1:s7vv7SMDPInkitQMuZzH615G7yWHdrU2r/Go7Bo71Rs= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rubyist/circuitbreaker v2.2.1+incompatible/go.mod h1:Ycs3JgJADPuzJDwffe12k6BZT8hxVi6lFK+gWYJLN4A= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20161028232340-1d7be4effb13/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.0.0-20161201235124-341000892f3d/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= @@ -261,64 +293,76 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20180711163814-62bca832be04/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= -github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= +github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= -go.opencensus.io v0.18.1-0.20181204023538-aab39bd6a98b/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= -go.opencensus.io v0.19.0/go.mod h1:AYeH0+ZxYyghG8diqaaIq/9P3VgCCt5GF2ldCY4dkFg= -golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190128193316-c7b33c32a30b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190424203555-c05e17bb3b2d h1:adrbvkTDn9rGnXg2IJDKozEpXXLZN89pdIA+Syt4/u0= -golang.org/x/crypto v0.0.0-20190424203555-c05e17bb3b2d/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181217023233-e147a9138326/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6 h1:FP8hkuE6yUEaJnK7O2eTuejKWwW+Rhfj80dQ2JcKxCU= -golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181218192612-074acd46bca6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190116161447-11f53e031339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190425145619-16072639606e h1:4ktJgTV34+N3qOZUc5fAaG3Pb11qzMm3PkAoTAgUZ2I= golang.org/x/sys v0.0.0-20190425145619-16072639606e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -331,25 +375,22 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181023010539-40a48ad93fbe/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181219222714-6e267b5cc78e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262 h1:qsl9y/CJx34tuA7QCPNp86JNJe4spst6Ff8MjvPUdPg= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= -google.golang.org/api v0.0.0-20181220000619-583d854617af/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= -google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/api v0.3.2/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= -google.golang.org/genproto v0.0.0-20181219182458-5a97ab628bfb/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= -google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.15.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= -google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -358,20 +399,22 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/fsnotify/fsnotify.v1 v1.3.0/go.mod h1:Fyux9zXlo4rWoMSIzpn9fDAYjalPqJ/K1qJ27s+7ltE= +gopkg.in/fsnotify/fsnotify.v1 v1.3.1/go.mod h1:Fyux9zXlo4rWoMSIzpn9fDAYjalPqJ/K1qJ27s+7ltE= gopkg.in/fsnotify/fsnotify.v1 v1.4.7/go.mod h1:Fyux9zXlo4rWoMSIzpn9fDAYjalPqJ/K1qJ27s+7ltE= -gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o= -gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.41.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/vmihailenco/msgpack.v2 v2.9.1/go.mod h1:/3Dn1Npt9+MYyLpYYXjInO/5jvMLamn+AEGwNEOatn8= +gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.1.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.0.0-20181213150558-05914d821849/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= k8s.io/api v0.0.0-20190313235455-40a48860b5ab h1:DG9A67baNpoeweOy2spF1OWHhnVY5KR7/Ek/+U1lVZc= k8s.io/api v0.0.0-20190313235455-40a48860b5ab/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= @@ -395,7 +438,5 @@ k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86 k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7 h1:8r+l4bNWjRlsFYlQJnKJ2p7s1YQPj4XyXiJVqDHRx7c= k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= -labix.org/v2/mgo v0.0.0-20140701140051-000000000287/go.mod h1:Lg7AYkt1uXJoR9oeSZ3W/8IXLdvOfIITgZnommstyz4= -launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/vendor/github.com/golang/protobuf/proto/decode.go b/vendor/github.com/golang/protobuf/proto/decode.go index d9aa3c42d6..63b0f08bef 100644 --- a/vendor/github.com/golang/protobuf/proto/decode.go +++ b/vendor/github.com/golang/protobuf/proto/decode.go @@ -186,7 +186,6 @@ func (p *Buffer) DecodeVarint() (x uint64, err error) { if b&0x80 == 0 { goto done } - // x -= 0x80 << 63 // Always zero. return 0, errOverflow diff --git a/vendor/github.com/golang/protobuf/proto/deprecated.go b/vendor/github.com/golang/protobuf/proto/deprecated.go new file mode 100644 index 0000000000..35b882c09a --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/deprecated.go @@ -0,0 +1,63 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2018 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import "errors" + +// Deprecated: do not use. +type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 } + +// Deprecated: do not use. +func GetStats() Stats { return Stats{} } + +// Deprecated: do not use. +func MarshalMessageSet(interface{}) ([]byte, error) { + return nil, errors.New("proto: not implemented") +} + +// Deprecated: do not use. +func UnmarshalMessageSet([]byte, interface{}) error { + return errors.New("proto: not implemented") +} + +// Deprecated: do not use. +func MarshalMessageSetJSON(interface{}) ([]byte, error) { + return nil, errors.New("proto: not implemented") +} + +// Deprecated: do not use. +func UnmarshalMessageSetJSON([]byte, interface{}) error { + return errors.New("proto: not implemented") +} + +// Deprecated: do not use. +func RegisterMessageSetType(Message, int32, string) {} diff --git a/vendor/github.com/golang/protobuf/proto/equal.go b/vendor/github.com/golang/protobuf/proto/equal.go index d4db5a1c14..f9b6e41b3c 100644 --- a/vendor/github.com/golang/protobuf/proto/equal.go +++ b/vendor/github.com/golang/protobuf/proto/equal.go @@ -246,7 +246,8 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool { return false } - m1, m2 := e1.value, e2.value + m1 := extensionAsLegacyType(e1.value) + m2 := extensionAsLegacyType(e2.value) if m1 == nil && m2 == nil { // Both have only encoded form. diff --git a/vendor/github.com/golang/protobuf/proto/extensions.go b/vendor/github.com/golang/protobuf/proto/extensions.go index 816a3b9d6c..fa88add30a 100644 --- a/vendor/github.com/golang/protobuf/proto/extensions.go +++ b/vendor/github.com/golang/protobuf/proto/extensions.go @@ -185,9 +185,25 @@ type Extension struct { // extension will have only enc set. When such an extension is // accessed using GetExtension (or GetExtensions) desc and value // will be set. - desc *ExtensionDesc + desc *ExtensionDesc + + // value is a concrete value for the extension field. Let the type of + // desc.ExtensionType be the "API type" and the type of Extension.value + // be the "storage type". The API type and storage type are the same except: + // * For scalars (except []byte), the API type uses *T, + // while the storage type uses T. + // * For repeated fields, the API type uses []T, while the storage type + // uses *[]T. + // + // The reason for the divergence is so that the storage type more naturally + // matches what is expected of when retrieving the values through the + // protobuf reflection APIs. + // + // The value may only be populated if desc is also populated. value interface{} - enc []byte + + // enc is the raw bytes for the extension field. + enc []byte } // SetRawExtension is for testing only. @@ -334,7 +350,7 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { // descriptors with the same field number. return nil, errors.New("proto: descriptor conflict") } - return e.value, nil + return extensionAsLegacyType(e.value), nil } if extension.ExtensionType == nil { @@ -349,11 +365,11 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { // Remember the decoded version and drop the encoded version. // That way it is safe to mutate what we return. - e.value = v + e.value = extensionAsStorageType(v) e.desc = extension e.enc = nil emap[extension.Field] = e - return e.value, nil + return extensionAsLegacyType(e.value), nil } // defaultExtensionValue returns the default value for extension. @@ -488,7 +504,7 @@ func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error } typ := reflect.TypeOf(extension.ExtensionType) if typ != reflect.TypeOf(value) { - return errors.New("proto: bad extension value type") + return fmt.Errorf("proto: bad extension value type. got: %T, want: %T", value, extension.ExtensionType) } // nil extension values need to be caught early, because the // encoder can't distinguish an ErrNil due to a nil extension @@ -500,7 +516,7 @@ func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error } extmap := epb.extensionsWrite() - extmap[extension.Field] = Extension{desc: extension, value: value} + extmap[extension.Field] = Extension{desc: extension, value: extensionAsStorageType(value)} return nil } @@ -541,3 +557,51 @@ func RegisterExtension(desc *ExtensionDesc) { func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { return extensionMaps[reflect.TypeOf(pb).Elem()] } + +// extensionAsLegacyType converts an value in the storage type as the API type. +// See Extension.value. +func extensionAsLegacyType(v interface{}) interface{} { + switch rv := reflect.ValueOf(v); rv.Kind() { + case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String: + // Represent primitive types as a pointer to the value. + rv2 := reflect.New(rv.Type()) + rv2.Elem().Set(rv) + v = rv2.Interface() + case reflect.Ptr: + // Represent slice types as the value itself. + switch rv.Type().Elem().Kind() { + case reflect.Slice: + if rv.IsNil() { + v = reflect.Zero(rv.Type().Elem()).Interface() + } else { + v = rv.Elem().Interface() + } + } + } + return v +} + +// extensionAsStorageType converts an value in the API type as the storage type. +// See Extension.value. +func extensionAsStorageType(v interface{}) interface{} { + switch rv := reflect.ValueOf(v); rv.Kind() { + case reflect.Ptr: + // Represent slice types as the value itself. + switch rv.Type().Elem().Kind() { + case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String: + if rv.IsNil() { + v = reflect.Zero(rv.Type().Elem()).Interface() + } else { + v = rv.Elem().Interface() + } + } + case reflect.Slice: + // Represent slice types as a pointer to the value. + if rv.Type().Elem().Kind() != reflect.Uint8 { + rv2 := reflect.New(rv.Type()) + rv2.Elem().Set(rv) + v = rv2.Interface() + } + } + return v +} diff --git a/vendor/github.com/golang/protobuf/proto/lib.go b/vendor/github.com/golang/protobuf/proto/lib.go index 75565cc6dc..fdd328bb7f 100644 --- a/vendor/github.com/golang/protobuf/proto/lib.go +++ b/vendor/github.com/golang/protobuf/proto/lib.go @@ -341,26 +341,6 @@ type Message interface { ProtoMessage() } -// Stats records allocation details about the protocol buffer encoders -// and decoders. Useful for tuning the library itself. -type Stats struct { - Emalloc uint64 // mallocs in encode - Dmalloc uint64 // mallocs in decode - Encode uint64 // number of encodes - Decode uint64 // number of decodes - Chit uint64 // number of cache hits - Cmiss uint64 // number of cache misses - Size uint64 // number of sizes -} - -// Set to true to enable stats collection. -const collectStats = false - -var stats Stats - -// GetStats returns a copy of the global Stats structure. -func GetStats() Stats { return stats } - // A Buffer is a buffer manager for marshaling and unmarshaling // protocol buffers. It may be reused between invocations to // reduce memory usage. It is not necessary to use a Buffer; @@ -960,13 +940,19 @@ func isProto3Zero(v reflect.Value) bool { return false } -// ProtoPackageIsVersion2 is referenced from generated protocol buffer files -// to assert that that code is compatible with this version of the proto package. -const ProtoPackageIsVersion2 = true +const ( + // ProtoPackageIsVersion3 is referenced from generated protocol buffer files + // to assert that that code is compatible with this version of the proto package. + ProtoPackageIsVersion3 = true + + // ProtoPackageIsVersion2 is referenced from generated protocol buffer files + // to assert that that code is compatible with this version of the proto package. + ProtoPackageIsVersion2 = true -// ProtoPackageIsVersion1 is referenced from generated protocol buffer files -// to assert that that code is compatible with this version of the proto package. -const ProtoPackageIsVersion1 = true + // ProtoPackageIsVersion1 is referenced from generated protocol buffer files + // to assert that that code is compatible with this version of the proto package. + ProtoPackageIsVersion1 = true +) // InternalMessageInfo is a type used internally by generated .pb.go files. // This type is not intended to be used by non-generated code. diff --git a/vendor/github.com/golang/protobuf/proto/message_set.go b/vendor/github.com/golang/protobuf/proto/message_set.go index 3b6ca41d5e..f48a756761 100644 --- a/vendor/github.com/golang/protobuf/proto/message_set.go +++ b/vendor/github.com/golang/protobuf/proto/message_set.go @@ -36,13 +36,7 @@ package proto */ import ( - "bytes" - "encoding/json" "errors" - "fmt" - "reflect" - "sort" - "sync" ) // errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. @@ -145,46 +139,9 @@ func skipVarint(buf []byte) []byte { return buf[i+1:] } -// MarshalMessageSet encodes the extension map represented by m in the message set wire format. -// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. -func MarshalMessageSet(exts interface{}) ([]byte, error) { - return marshalMessageSet(exts, false) -} - -// marshaMessageSet implements above function, with the opt to turn on / off deterministic during Marshal. -func marshalMessageSet(exts interface{}, deterministic bool) ([]byte, error) { - switch exts := exts.(type) { - case *XXX_InternalExtensions: - var u marshalInfo - siz := u.sizeMessageSet(exts) - b := make([]byte, 0, siz) - return u.appendMessageSet(b, exts, deterministic) - - case map[int32]Extension: - // This is an old-style extension map. - // Wrap it in a new-style XXX_InternalExtensions. - ie := XXX_InternalExtensions{ - p: &struct { - mu sync.Mutex - extensionMap map[int32]Extension - }{ - extensionMap: exts, - }, - } - - var u marshalInfo - siz := u.sizeMessageSet(&ie) - b := make([]byte, 0, siz) - return u.appendMessageSet(b, &ie, deterministic) - - default: - return nil, errors.New("proto: not an extension map") - } -} - -// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. +// unmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. // It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option. -func UnmarshalMessageSet(buf []byte, exts interface{}) error { +func unmarshalMessageSet(buf []byte, exts interface{}) error { var m map[int32]Extension switch exts := exts.(type) { case *XXX_InternalExtensions: @@ -222,93 +179,3 @@ func UnmarshalMessageSet(buf []byte, exts interface{}) error { } return nil } - -// MarshalMessageSetJSON encodes the extension map represented by m in JSON format. -// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. -func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { - var m map[int32]Extension - switch exts := exts.(type) { - case *XXX_InternalExtensions: - var mu sync.Locker - m, mu = exts.extensionsRead() - if m != nil { - // Keep the extensions map locked until we're done marshaling to prevent - // races between marshaling and unmarshaling the lazily-{en,de}coded - // values. - mu.Lock() - defer mu.Unlock() - } - case map[int32]Extension: - m = exts - default: - return nil, errors.New("proto: not an extension map") - } - var b bytes.Buffer - b.WriteByte('{') - - // Process the map in key order for deterministic output. - ids := make([]int32, 0, len(m)) - for id := range m { - ids = append(ids, id) - } - sort.Sort(int32Slice(ids)) // int32Slice defined in text.go - - for i, id := range ids { - ext := m[id] - msd, ok := messageSetMap[id] - if !ok { - // Unknown type; we can't render it, so skip it. - continue - } - - if i > 0 && b.Len() > 1 { - b.WriteByte(',') - } - - fmt.Fprintf(&b, `"[%s]":`, msd.name) - - x := ext.value - if x == nil { - x = reflect.New(msd.t.Elem()).Interface() - if err := Unmarshal(ext.enc, x.(Message)); err != nil { - return nil, err - } - } - d, err := json.Marshal(x) - if err != nil { - return nil, err - } - b.Write(d) - } - b.WriteByte('}') - return b.Bytes(), nil -} - -// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. -// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. -func UnmarshalMessageSetJSON(buf []byte, exts interface{}) error { - // Common-case fast path. - if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { - return nil - } - - // This is fairly tricky, and it's not clear that it is needed. - return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented") -} - -// A global registry of types that can be used in a MessageSet. - -var messageSetMap = make(map[int32]messageSetDesc) - -type messageSetDesc struct { - t reflect.Type // pointer to struct - name string -} - -// RegisterMessageSetType is called from the generated code. -func RegisterMessageSetType(m Message, fieldNum int32, name string) { - messageSetMap[fieldNum] = messageSetDesc{ - t: reflect.TypeOf(m), - name: name, - } -} diff --git a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go index b6cad90834..94fa9194a8 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go @@ -79,10 +79,13 @@ func toPointer(i *Message) pointer { // toAddrPointer converts an interface to a pointer that points to // the interface data. -func toAddrPointer(i *interface{}, isptr bool) pointer { +func toAddrPointer(i *interface{}, isptr, deref bool) pointer { v := reflect.ValueOf(*i) u := reflect.New(v.Type()) u.Elem().Set(v) + if deref { + u = u.Elem() + } return pointer{v: u} } diff --git a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go index d55a335d94..dbfffe071b 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go @@ -85,16 +85,21 @@ func toPointer(i *Message) pointer { // toAddrPointer converts an interface to a pointer that points to // the interface data. -func toAddrPointer(i *interface{}, isptr bool) pointer { +func toAddrPointer(i *interface{}, isptr, deref bool) (p pointer) { // Super-tricky - read or get the address of data word of interface value. if isptr { // The interface is of pointer type, thus it is a direct interface. // The data word is the pointer data itself. We take its address. - return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} + p = pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} + } else { + // The interface is not of pointer type. The data word is the pointer + // to the data. + p = pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} } - // The interface is not of pointer type. The data word is the pointer - // to the data. - return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} + if deref { + p.p = *(*unsafe.Pointer)(p.p) + } + return p } // valToPointer converts v to a pointer. v must be of pointer type. diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go index 50b99b83a8..79668ff5c5 100644 --- a/vendor/github.com/golang/protobuf/proto/properties.go +++ b/vendor/github.com/golang/protobuf/proto/properties.go @@ -334,9 +334,6 @@ func GetProperties(t reflect.Type) *StructProperties { sprop, ok := propertiesMap[t] propertiesMu.RUnlock() if ok { - if collectStats { - stats.Chit++ - } return sprop } @@ -346,17 +343,20 @@ func GetProperties(t reflect.Type) *StructProperties { return sprop } +type ( + oneofFuncsIface interface { + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + } + oneofWrappersIface interface { + XXX_OneofWrappers() []interface{} + } +) + // getPropertiesLocked requires that propertiesMu is held. func getPropertiesLocked(t reflect.Type) *StructProperties { if prop, ok := propertiesMap[t]; ok { - if collectStats { - stats.Chit++ - } return prop } - if collectStats { - stats.Cmiss++ - } prop := new(StructProperties) // in case of recursive protos, fill this in now. @@ -391,13 +391,14 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { // Re-order prop.order. sort.Sort(prop) - type oneofMessage interface { - XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + var oots []interface{} + switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { + case oneofFuncsIface: + _, _, _, oots = m.XXX_OneofFuncs() + case oneofWrappersIface: + oots = m.XXX_OneofWrappers() } - if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { - var oots []interface{} - _, _, _, oots = om.XXX_OneofFuncs() - + if len(oots) > 0 { // Interpret oneof metadata. prop.OneofTypes = make(map[string]*OneofProperties) for _, oot := range oots { diff --git a/vendor/github.com/golang/protobuf/proto/table_marshal.go b/vendor/github.com/golang/protobuf/proto/table_marshal.go index b16794496f..5cb11fa955 100644 --- a/vendor/github.com/golang/protobuf/proto/table_marshal.go +++ b/vendor/github.com/golang/protobuf/proto/table_marshal.go @@ -87,6 +87,7 @@ type marshalElemInfo struct { sizer sizer marshaler marshaler isptr bool // elem is pointer typed, thus interface of this type is a direct interface (extension only) + deref bool // dereference the pointer before operating on it; implies isptr } var ( @@ -320,8 +321,11 @@ func (u *marshalInfo) computeMarshalInfo() { // get oneof implementers var oneofImplementers []interface{} - if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { + switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { + case oneofFuncsIface: _, _, _, oneofImplementers = m.XXX_OneofFuncs() + case oneofWrappersIface: + oneofImplementers = m.XXX_OneofWrappers() } n := t.NumField() @@ -407,13 +411,22 @@ func (u *marshalInfo) getExtElemInfo(desc *ExtensionDesc) *marshalElemInfo { panic("tag is not an integer") } wt := wiretype(tags[0]) + if t.Kind() == reflect.Ptr && t.Elem().Kind() != reflect.Struct { + t = t.Elem() + } sizer, marshaler := typeMarshaler(t, tags, false, false) + var deref bool + if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 { + t = reflect.PtrTo(t) + deref = true + } e = &marshalElemInfo{ wiretag: uint64(tag)<<3 | wt, tagsize: SizeVarint(uint64(tag) << 3), sizer: sizer, marshaler: marshaler, isptr: t.Kind() == reflect.Ptr, + deref: deref, } // update cache @@ -448,7 +461,7 @@ func (fi *marshalFieldInfo) computeMarshalFieldInfo(f *reflect.StructField) { func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []interface{}) { fi.field = toField(f) - fi.wiretag = 1<<31 - 1 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire. + fi.wiretag = math.MaxInt32 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire. fi.isPointer = true fi.sizer, fi.marshaler = makeOneOfMarshaler(fi, f) fi.oneofElems = make(map[reflect.Type]*marshalElemInfo) @@ -476,10 +489,6 @@ func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofI } } -type oneofMessage interface { - XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) -} - // wiretype returns the wire encoding of the type. func wiretype(encoding string) uint64 { switch encoding { @@ -2310,8 +2319,8 @@ func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) { for _, k := range m.MapKeys() { ki := k.Interface() vi := m.MapIndex(k).Interface() - kaddr := toAddrPointer(&ki, false) // pointer to key - vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value + kaddr := toAddrPointer(&ki, false, false) // pointer to key + vaddr := toAddrPointer(&vi, valIsPtr, false) // pointer to value siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) n += siz + SizeVarint(uint64(siz)) + tagsize } @@ -2329,8 +2338,8 @@ func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) { for _, k := range keys { ki := k.Interface() vi := m.MapIndex(k).Interface() - kaddr := toAddrPointer(&ki, false) // pointer to key - vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value + kaddr := toAddrPointer(&ki, false, false) // pointer to key + vaddr := toAddrPointer(&vi, valIsPtr, false) // pointer to value b = appendVarint(b, tag) siz := keySizer(kaddr, 1) + valCachedSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) b = appendVarint(b, uint64(siz)) @@ -2399,7 +2408,7 @@ func (u *marshalInfo) sizeExtensions(ext *XXX_InternalExtensions) int { // the last time this function was called. ei := u.getExtElemInfo(e.desc) v := e.value - p := toAddrPointer(&v, ei.isptr) + p := toAddrPointer(&v, ei.isptr, ei.deref) n += ei.sizer(p, ei.tagsize) } mu.Unlock() @@ -2434,7 +2443,7 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de ei := u.getExtElemInfo(e.desc) v := e.value - p := toAddrPointer(&v, ei.isptr) + p := toAddrPointer(&v, ei.isptr, ei.deref) b, err = ei.marshaler(b, p, ei.wiretag, deterministic) if !nerr.Merge(err) { return b, err @@ -2465,7 +2474,7 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de ei := u.getExtElemInfo(e.desc) v := e.value - p := toAddrPointer(&v, ei.isptr) + p := toAddrPointer(&v, ei.isptr, ei.deref) b, err = ei.marshaler(b, p, ei.wiretag, deterministic) if !nerr.Merge(err) { return b, err @@ -2510,7 +2519,7 @@ func (u *marshalInfo) sizeMessageSet(ext *XXX_InternalExtensions) int { ei := u.getExtElemInfo(e.desc) v := e.value - p := toAddrPointer(&v, ei.isptr) + p := toAddrPointer(&v, ei.isptr, ei.deref) n += ei.sizer(p, 1) // message, tag = 3 (size=1) } mu.Unlock() @@ -2553,7 +2562,7 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de ei := u.getExtElemInfo(e.desc) v := e.value - p := toAddrPointer(&v, ei.isptr) + p := toAddrPointer(&v, ei.isptr, ei.deref) b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) if !nerr.Merge(err) { return b, err @@ -2591,7 +2600,7 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de ei := u.getExtElemInfo(e.desc) v := e.value - p := toAddrPointer(&v, ei.isptr) + p := toAddrPointer(&v, ei.isptr, ei.deref) b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) b = append(b, 1<<3|WireEndGroup) if !nerr.Merge(err) { @@ -2621,7 +2630,7 @@ func (u *marshalInfo) sizeV1Extensions(m map[int32]Extension) int { ei := u.getExtElemInfo(e.desc) v := e.value - p := toAddrPointer(&v, ei.isptr) + p := toAddrPointer(&v, ei.isptr, ei.deref) n += ei.sizer(p, ei.tagsize) } return n @@ -2656,7 +2665,7 @@ func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, determ ei := u.getExtElemInfo(e.desc) v := e.value - p := toAddrPointer(&v, ei.isptr) + p := toAddrPointer(&v, ei.isptr, ei.deref) b, err = ei.marshaler(b, p, ei.wiretag, deterministic) if !nerr.Merge(err) { return b, err diff --git a/vendor/github.com/golang/protobuf/proto/table_unmarshal.go b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go index ebf1caa56a..acee2fc529 100644 --- a/vendor/github.com/golang/protobuf/proto/table_unmarshal.go +++ b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go @@ -136,7 +136,7 @@ func (u *unmarshalInfo) unmarshal(m pointer, b []byte) error { u.computeUnmarshalInfo() } if u.isMessageSet { - return UnmarshalMessageSet(b, m.offset(u.extensions).toExtensions()) + return unmarshalMessageSet(b, m.offset(u.extensions).toExtensions()) } var reqMask uint64 // bitmask of required fields we've seen. var errLater error @@ -362,46 +362,48 @@ func (u *unmarshalInfo) computeUnmarshalInfo() { } // Find any types associated with oneof fields. - // TODO: XXX_OneofFuncs returns more info than we need. Get rid of some of it? - fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("XXX_OneofFuncs") - if fn.IsValid() { - res := fn.Call(nil)[3] // last return value from XXX_OneofFuncs: []interface{} - for i := res.Len() - 1; i >= 0; i-- { - v := res.Index(i) // interface{} - tptr := reflect.ValueOf(v.Interface()).Type() // *Msg_X - typ := tptr.Elem() // Msg_X - - f := typ.Field(0) // oneof implementers have one field - baseUnmarshal := fieldUnmarshaler(&f) - tags := strings.Split(f.Tag.Get("protobuf"), ",") - fieldNum, err := strconv.Atoi(tags[1]) - if err != nil { - panic("protobuf tag field not an integer: " + tags[1]) - } - var name string - for _, tag := range tags { - if strings.HasPrefix(tag, "name=") { - name = strings.TrimPrefix(tag, "name=") - break - } + var oneofImplementers []interface{} + switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { + case oneofFuncsIface: + _, _, _, oneofImplementers = m.XXX_OneofFuncs() + case oneofWrappersIface: + oneofImplementers = m.XXX_OneofWrappers() + } + for _, v := range oneofImplementers { + tptr := reflect.TypeOf(v) // *Msg_X + typ := tptr.Elem() // Msg_X + + f := typ.Field(0) // oneof implementers have one field + baseUnmarshal := fieldUnmarshaler(&f) + tags := strings.Split(f.Tag.Get("protobuf"), ",") + fieldNum, err := strconv.Atoi(tags[1]) + if err != nil { + panic("protobuf tag field not an integer: " + tags[1]) + } + var name string + for _, tag := range tags { + if strings.HasPrefix(tag, "name=") { + name = strings.TrimPrefix(tag, "name=") + break } + } - // Find the oneof field that this struct implements. - // Might take O(n^2) to process all of the oneofs, but who cares. - for _, of := range oneofFields { - if tptr.Implements(of.ityp) { - // We have found the corresponding interface for this struct. - // That lets us know where this struct should be stored - // when we encounter it during unmarshaling. - unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal) - u.setTag(fieldNum, of.field, unmarshal, 0, name) - } + // Find the oneof field that this struct implements. + // Might take O(n^2) to process all of the oneofs, but who cares. + for _, of := range oneofFields { + if tptr.Implements(of.ityp) { + // We have found the corresponding interface for this struct. + // That lets us know where this struct should be stored + // when we encounter it during unmarshaling. + unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal) + u.setTag(fieldNum, of.field, unmarshal, 0, name) } } + } // Get extension ranges, if any. - fn = reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray") + fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray") if fn.IsValid() { if !u.extensions.IsValid() && !u.oldExtensions.IsValid() { panic("a message with extensions, but no extensions field in " + t.Name()) @@ -1948,7 +1950,7 @@ func encodeVarint(b []byte, x uint64) []byte { // If there is an error, it returns 0,0. func decodeVarint(b []byte) (uint64, int) { var x, y uint64 - if len(b) <= 0 { + if len(b) == 0 { goto bad } x = uint64(b[0]) diff --git a/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go b/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go index e3c56d3ffa..78ee523349 100644 --- a/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go +++ b/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go @@ -1,11 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: google/protobuf/any.proto -package any // import "github.com/golang/protobuf/ptypes/any" +package any -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -16,7 +18,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // `Any` contains an arbitrary serialized protocol buffer message along with a // URL that describes the type of the serialized message. @@ -99,17 +101,18 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // } // type Any struct { - // A URL/resource name whose content describes the type of the - // serialized protocol buffer message. + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). // - // For URLs which use the scheme `http`, `https`, or no scheme, the - // following restrictions and interpretations apply: + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: // // * If no scheme is provided, `https` is assumed. - // * The last segment of the URL's path must represent the fully - // qualified name of the type (as in `path/google.protobuf.Duration`). - // The name should be in a canonical form (e.g., leading "." is - // not accepted). // * An HTTP GET on the URL must yield a [google.protobuf.Type][] // value in binary format, or produce an error. // * Applications are allowed to cache lookup results based on the @@ -118,6 +121,10 @@ type Any struct { // on changes to types. (Use versioned type names to manage // breaking changes.) // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. + // // Schemes other than `http`, `https` (or the empty scheme) might be // used with implementation specific semantics. // @@ -133,17 +140,19 @@ func (m *Any) Reset() { *m = Any{} } func (m *Any) String() string { return proto.CompactTextString(m) } func (*Any) ProtoMessage() {} func (*Any) Descriptor() ([]byte, []int) { - return fileDescriptor_any_744b9ca530f228db, []int{0} + return fileDescriptor_b53526c13ae22eb4, []int{0} } + func (*Any) XXX_WellKnownType() string { return "Any" } + func (m *Any) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Any.Unmarshal(m, b) } func (m *Any) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Any.Marshal(b, m, deterministic) } -func (dst *Any) XXX_Merge(src proto.Message) { - xxx_messageInfo_Any.Merge(dst, src) +func (m *Any) XXX_Merge(src proto.Message) { + xxx_messageInfo_Any.Merge(m, src) } func (m *Any) XXX_Size() int { return xxx_messageInfo_Any.Size(m) @@ -172,9 +181,9 @@ func init() { proto.RegisterType((*Any)(nil), "google.protobuf.Any") } -func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor_any_744b9ca530f228db) } +func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor_b53526c13ae22eb4) } -var fileDescriptor_any_744b9ca530f228db = []byte{ +var fileDescriptor_b53526c13ae22eb4 = []byte{ // 185 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcc, 0xab, 0xd4, diff --git a/vendor/github.com/golang/protobuf/ptypes/any/any.proto b/vendor/github.com/golang/protobuf/ptypes/any/any.proto index c748667623..4932942558 100644 --- a/vendor/github.com/golang/protobuf/ptypes/any/any.proto +++ b/vendor/github.com/golang/protobuf/ptypes/any/any.proto @@ -120,17 +120,18 @@ option objc_class_prefix = "GPB"; // } // message Any { - // A URL/resource name whose content describes the type of the - // serialized protocol buffer message. + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). // - // For URLs which use the scheme `http`, `https`, or no scheme, the - // following restrictions and interpretations apply: + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: // // * If no scheme is provided, `https` is assumed. - // * The last segment of the URL's path must represent the fully - // qualified name of the type (as in `path/google.protobuf.Duration`). - // The name should be in a canonical form (e.g., leading "." is - // not accepted). // * An HTTP GET on the URL must yield a [google.protobuf.Type][] // value in binary format, or produce an error. // * Applications are allowed to cache lookup results based on the @@ -139,6 +140,10 @@ message Any { // on changes to types. (Use versioned type names to manage // breaking changes.) // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. + // // Schemes other than `http`, `https` (or the empty scheme) might be // used with implementation specific semantics. // diff --git a/vendor/github.com/golang/protobuf/ptypes/duration.go b/vendor/github.com/golang/protobuf/ptypes/duration.go index 65cb0f8eb5..26d1ca2fb5 100644 --- a/vendor/github.com/golang/protobuf/ptypes/duration.go +++ b/vendor/github.com/golang/protobuf/ptypes/duration.go @@ -82,7 +82,7 @@ func Duration(p *durpb.Duration) (time.Duration, error) { return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p) } if p.Nanos != 0 { - d += time.Duration(p.Nanos) + d += time.Duration(p.Nanos) * time.Nanosecond if (d < 0) != (p.Nanos < 0) { return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p) } diff --git a/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go b/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go index a7beb2c414..0d681ee21a 100644 --- a/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go +++ b/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go @@ -1,11 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: google/protobuf/duration.proto -package duration // import "github.com/golang/protobuf/ptypes/duration" +package duration -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -16,7 +18,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // A Duration represents a signed, fixed-length span of time represented // as a count of seconds and fractions of seconds at nanosecond @@ -99,17 +101,19 @@ func (m *Duration) Reset() { *m = Duration{} } func (m *Duration) String() string { return proto.CompactTextString(m) } func (*Duration) ProtoMessage() {} func (*Duration) Descriptor() ([]byte, []int) { - return fileDescriptor_duration_e7d612259e3f0613, []int{0} + return fileDescriptor_23597b2ebd7ac6c5, []int{0} } + func (*Duration) XXX_WellKnownType() string { return "Duration" } + func (m *Duration) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Duration.Unmarshal(m, b) } func (m *Duration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Duration.Marshal(b, m, deterministic) } -func (dst *Duration) XXX_Merge(src proto.Message) { - xxx_messageInfo_Duration.Merge(dst, src) +func (m *Duration) XXX_Merge(src proto.Message) { + xxx_messageInfo_Duration.Merge(m, src) } func (m *Duration) XXX_Size() int { return xxx_messageInfo_Duration.Size(m) @@ -138,11 +142,9 @@ func init() { proto.RegisterType((*Duration)(nil), "google.protobuf.Duration") } -func init() { - proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor_duration_e7d612259e3f0613) -} +func init() { proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor_23597b2ebd7ac6c5) } -var fileDescriptor_duration_e7d612259e3f0613 = []byte{ +var fileDescriptor_23597b2ebd7ac6c5 = []byte{ // 190 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a, diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp.go b/vendor/github.com/golang/protobuf/ptypes/timestamp.go index 47f10dbc2c..8da0df01ac 100644 --- a/vendor/github.com/golang/protobuf/ptypes/timestamp.go +++ b/vendor/github.com/golang/protobuf/ptypes/timestamp.go @@ -111,11 +111,9 @@ func TimestampNow() *tspb.Timestamp { // TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. // It returns an error if the resulting Timestamp is invalid. func TimestampProto(t time.Time) (*tspb.Timestamp, error) { - seconds := t.Unix() - nanos := int32(t.Sub(time.Unix(seconds, 0))) ts := &tspb.Timestamp{ - Seconds: seconds, - Nanos: nanos, + Seconds: t.Unix(), + Nanos: int32(t.Nanosecond()), } if err := validateTimestamp(ts); err != nil { return nil, err diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go index 8e76ae9763..31cd846de9 100644 --- a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go +++ b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go @@ -1,11 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: google/protobuf/timestamp.proto -package timestamp // import "github.com/golang/protobuf/ptypes/timestamp" +package timestamp -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -16,7 +18,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // A Timestamp represents a point in time independent of any time zone // or calendar, represented as seconds and fractions of seconds at @@ -81,7 +83,9 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone -// is required, though only UTC (as indicated by "Z") is presently supported. +// is required. A proto3 JSON serializer should always use UTC (as indicated by +// "Z") when printing the Timestamp type and a proto3 JSON parser should be +// able to accept both UTC and other timezones (as indicated by an offset). // // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past // 01:30 UTC on January 15, 2017. @@ -92,8 +96,8 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one // can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( -// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--) -// to obtain a formatter capable of generating timestamps in this format. +// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime-- +// ) to obtain a formatter capable of generating timestamps in this format. // // type Timestamp struct { @@ -115,17 +119,19 @@ func (m *Timestamp) Reset() { *m = Timestamp{} } func (m *Timestamp) String() string { return proto.CompactTextString(m) } func (*Timestamp) ProtoMessage() {} func (*Timestamp) Descriptor() ([]byte, []int) { - return fileDescriptor_timestamp_b826e8e5fba671a8, []int{0} + return fileDescriptor_292007bbfe81227e, []int{0} } + func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" } + func (m *Timestamp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Timestamp.Unmarshal(m, b) } func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Timestamp.Marshal(b, m, deterministic) } -func (dst *Timestamp) XXX_Merge(src proto.Message) { - xxx_messageInfo_Timestamp.Merge(dst, src) +func (m *Timestamp) XXX_Merge(src proto.Message) { + xxx_messageInfo_Timestamp.Merge(m, src) } func (m *Timestamp) XXX_Size() int { return xxx_messageInfo_Timestamp.Size(m) @@ -154,11 +160,9 @@ func init() { proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp") } -func init() { - proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor_timestamp_b826e8e5fba671a8) -} +func init() { proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor_292007bbfe81227e) } -var fileDescriptor_timestamp_b826e8e5fba671a8 = []byte{ +var fileDescriptor_292007bbfe81227e = []byte{ // 191 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xc9, 0xcc, 0x4d, diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto index 06750ab1f1..eafb3fa03a 100644 --- a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto +++ b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto @@ -103,7 +103,9 @@ option objc_class_prefix = "GPB"; // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone -// is required, though only UTC (as indicated by "Z") is presently supported. +// is required. A proto3 JSON serializer should always use UTC (as indicated by +// "Z") when printing the Timestamp type and a proto3 JSON parser should be +// able to accept both UTC and other timezones (as indicated by an offset). // // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past // 01:30 UTC on January 15, 2017. @@ -114,8 +116,8 @@ option objc_class_prefix = "GPB"; // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one // can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( -// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--) -// to obtain a formatter capable of generating timestamps in this format. +// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime-- +// ) to obtain a formatter capable of generating timestamps in this format. // // message Timestamp { diff --git a/vendor/github.com/improbable-eng/thanos/pkg/runutil/runutil.go b/vendor/github.com/improbable-eng/thanos/pkg/runutil/runutil.go index 10e58ea4e0..aa0d1b13d5 100644 --- a/vendor/github.com/improbable-eng/thanos/pkg/runutil/runutil.go +++ b/vendor/github.com/improbable-eng/thanos/pkg/runutil/runutil.go @@ -49,7 +49,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/pkg/errors" - "github.com/prometheus/tsdb" + tsdberrors "github.com/prometheus/tsdb/errors" ) // Repeat executes f every interval seconds until stopc is closed. @@ -111,7 +111,7 @@ func CloseWithLogOnErr(logger log.Logger, closer io.Closer, format string, a ... // CloseWithErrCapture runs function and on error return error by argument including the given error (usually // from caller function). func CloseWithErrCapture(err *error, closer io.Closer, format string, a ...interface{}) { - merr := tsdb.MultiError{} + merr := tsdberrors.MultiError{} merr.Add(*err) merr.Add(errors.Wrapf(closer.Close(), format, a...)) diff --git a/vendor/github.com/prometheus/client_golang/prometheus/collector.go b/vendor/github.com/prometheus/client_golang/prometheus/collector.go index c0d70b2faf..1e839650d4 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/collector.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/collector.go @@ -79,7 +79,7 @@ type Collector interface { // of the Describe method. If a Collector sometimes collects no metrics at all // (for example vectors like CounterVec, GaugeVec, etc., which only collect // metrics after a metric with a fully specified label set has been accessed), -// it might even get registered as an unchecked Collecter (cf. the Register +// it might even get registered as an unchecked Collector (cf. the Register // method of the Registerer interface). Hence, only use this shortcut // implementation of Describe if you are certain to fulfill the contract. // diff --git a/vendor/github.com/prometheus/client_golang/prometheus/doc.go b/vendor/github.com/prometheus/client_golang/prometheus/doc.go index 5d9525defc..1e0d578ee7 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/doc.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/doc.go @@ -122,13 +122,13 @@ // the Collect method. The Describe method has to return separate Desc // instances, representative of the “throw-away” metrics to be created later. // NewDesc comes in handy to create those Desc instances. Alternatively, you -// could return no Desc at all, which will marke the Collector “unchecked”. No -// checks are porformed at registration time, but metric consistency will still +// could return no Desc at all, which will mark the Collector “unchecked”. No +// checks are performed at registration time, but metric consistency will still // be ensured at scrape time, i.e. any inconsistencies will lead to scrape // errors. Thus, with unchecked Collectors, the responsibility to not collect // metrics that lead to inconsistencies in the total scrape result lies with the // implementer of the Collector. While this is not a desirable state, it is -// sometimes necessary. The typical use case is a situatios where the exact +// sometimes necessary. The typical use case is a situation where the exact // metrics to be returned by a Collector cannot be predicted at registration // time, but the implementer has sufficient knowledge of the whole system to // guarantee metric consistency. diff --git a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go index f88da707bc..20ee1afb5d 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go @@ -204,8 +204,8 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } } } - // Finally we know the final length of h.upperBounds and can make counts - // for both states: + // Finally we know the final length of h.upperBounds and can make buckets + // for both counts: h.counts[0].buckets = make([]uint64, len(h.upperBounds)) h.counts[1].buckets = make([]uint64, len(h.upperBounds)) diff --git a/vendor/github.com/prometheus/client_golang/prometheus/http.go b/vendor/github.com/prometheus/client_golang/prometheus/http.go index 9f0875bfc8..0fa339aec0 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/http.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/http.go @@ -34,7 +34,6 @@ import ( const ( contentTypeHeader = "Content-Type" - contentLengthHeader = "Content-Length" contentEncodingHeader = "Content-Encoding" acceptEncodingHeader = "Accept-Encoding" ) diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go index 67b56d37cf..5de5bbc685 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go @@ -38,7 +38,6 @@ type delegator interface { type responseWriterDelegator struct { http.ResponseWriter - handler, method string status int written int64 wroteHeader bool diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go index 668eb6b3c9..b137c88307 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go @@ -47,7 +47,6 @@ import ( const ( contentTypeHeader = "Content-Type" - contentLengthHeader = "Content-Length" contentEncodingHeader = "Content-Encoding" acceptEncodingHeader = "Accept-Encoding" ) diff --git a/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/vendor/github.com/prometheus/client_golang/prometheus/registry.go index b5e70b93fa..f2fb67aeeb 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/registry.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/registry.go @@ -680,7 +680,7 @@ func processMetric( // Gatherers is a slice of Gatherer instances that implements the Gatherer // interface itself. Its Gather method calls Gather on all Gatherers in the // slice in order and returns the merged results. Errors returned from the -// Gather calles are all returned in a flattened MultiError. Duplicate and +// Gather calls are all returned in a flattened MultiError. Duplicate and // inconsistent Metrics are skipped (first occurrence in slice order wins) and // reported in the returned error. // diff --git a/vendor/github.com/prometheus/client_golang/prometheus/summary.go b/vendor/github.com/prometheus/client_golang/prometheus/summary.go index 2980614dff..e4c87145cb 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/summary.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/summary.go @@ -16,8 +16,10 @@ package prometheus import ( "fmt" "math" + "runtime" "sort" "sync" + "sync/atomic" "time" "github.com/beorn7/perks/quantile" @@ -151,7 +153,7 @@ type SummaryOpts struct { BufCap uint32 } -// Great fuck-up with the sliding-window decay algorithm... The Merge method of +// Problem with the sliding-window decay algorithm... The Merge method of // perk/quantile is actually not working as advertised - and it might be // unfixable, as the underlying algorithm is apparently not capable of merging // summaries in the first place. To avoid using Merge, we are currently adding @@ -214,6 +216,17 @@ func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary { opts.BufCap = DefBufCap } + if len(opts.Objectives) == 0 { + // Use the lock-free implementation of a Summary without objectives. + s := &noObjectivesSummary{ + desc: desc, + labelPairs: makeLabelPairs(desc, labelValues), + counts: [2]*summaryCounts{&summaryCounts{}, &summaryCounts{}}, + } + s.init(s) // Init self-collection. + return s + } + s := &summary{ desc: desc, @@ -382,6 +395,142 @@ func (s *summary) swapBufs(now time.Time) { } } +type summaryCounts struct { + // sumBits contains the bits of the float64 representing the sum of all + // observations. sumBits and count have to go first in the struct to + // guarantee alignment for atomic operations. + // http://golang.org/pkg/sync/atomic/#pkg-note-BUG + sumBits uint64 + count uint64 +} + +type noObjectivesSummary struct { + // countAndHotIdx is a complicated one. For lock-free yet atomic + // observations, we need to save the total count of observations again, + // combined with the index of the currently-hot counts struct, so that + // we can perform the operation on both values atomically. The least + // significant bit defines the hot counts struct. The remaining 63 bits + // represent the total count of observations. This happens under the + // assumption that the 63bit count will never overflow. Rationale: An + // observations takes about 30ns. Let's assume it could happen in + // 10ns. Overflowing the counter will then take at least (2^63)*10ns, + // which is about 3000 years. + // + // This has to be first in the struct for 64bit alignment. See + // http://golang.org/pkg/sync/atomic/#pkg-note-BUG + countAndHotIdx uint64 + + selfCollector + desc *Desc + writeMtx sync.Mutex // Only used in the Write method. + + // Two counts, one is "hot" for lock-free observations, the other is + // "cold" for writing out a dto.Metric. It has to be an array of + // pointers to guarantee 64bit alignment of the histogramCounts, see + // http://golang.org/pkg/sync/atomic/#pkg-note-BUG. + counts [2]*summaryCounts + hotIdx int // Index of currently-hot counts. Only used within Write. + + labelPairs []*dto.LabelPair +} + +func (s *noObjectivesSummary) Desc() *Desc { + return s.desc +} + +func (s *noObjectivesSummary) Observe(v float64) { + // We increment s.countAndHotIdx by 2 so that the counter in the upper + // 63 bits gets incremented by 1. At the same time, we get the new value + // back, which we can use to find the currently-hot counts. + n := atomic.AddUint64(&s.countAndHotIdx, 2) + hotCounts := s.counts[n%2] + + for { + oldBits := atomic.LoadUint64(&hotCounts.sumBits) + newBits := math.Float64bits(math.Float64frombits(oldBits) + v) + if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) { + break + } + } + // Increment count last as we take it as a signal that the observation + // is complete. + atomic.AddUint64(&hotCounts.count, 1) +} + +func (s *noObjectivesSummary) Write(out *dto.Metric) error { + var ( + sum = &dto.Summary{} + hotCounts, coldCounts *summaryCounts + count uint64 + ) + + // For simplicity, we mutex the rest of this method. It is not in the + // hot path, i.e. Observe is called much more often than Write. The + // complication of making Write lock-free isn't worth it. + s.writeMtx.Lock() + defer s.writeMtx.Unlock() + + // This is a bit arcane, which is why the following spells out this if + // clause in English: + // + // If the currently-hot counts struct is #0, we atomically increment + // s.countAndHotIdx by 1 so that from now on Observe will use the counts + // struct #1. Furthermore, the atomic increment gives us the new value, + // which, in its most significant 63 bits, tells us the count of + // observations done so far up to and including currently ongoing + // observations still using the counts struct just changed from hot to + // cold. To have a normal uint64 for the count, we bitshift by 1 and + // save the result in count. We also set s.hotIdx to 1 for the next + // Write call, and we will refer to counts #1 as hotCounts and to counts + // #0 as coldCounts. + // + // If the currently-hot counts struct is #1, we do the corresponding + // things the other way round. We have to _decrement_ s.countAndHotIdx + // (which is a bit arcane in itself, as we have to express -1 with an + // unsigned int...). + if s.hotIdx == 0 { + count = atomic.AddUint64(&s.countAndHotIdx, 1) >> 1 + s.hotIdx = 1 + hotCounts = s.counts[1] + coldCounts = s.counts[0] + } else { + count = atomic.AddUint64(&s.countAndHotIdx, ^uint64(0)) >> 1 // Decrement. + s.hotIdx = 0 + hotCounts = s.counts[0] + coldCounts = s.counts[1] + } + + // Now we have to wait for the now-declared-cold counts to actually cool + // down, i.e. wait for all observations still using it to finish. That's + // the case once the count in the cold counts struct is the same as the + // one atomically retrieved from the upper 63bits of s.countAndHotIdx. + for { + if count == atomic.LoadUint64(&coldCounts.count) { + break + } + runtime.Gosched() // Let observations get work done. + } + + sum.SampleCount = proto.Uint64(count) + sum.SampleSum = proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.sumBits))) + + out.Summary = sum + out.Label = s.labelPairs + + // Finally add all the cold counts to the new hot counts and reset the cold counts. + atomic.AddUint64(&hotCounts.count, count) + atomic.StoreUint64(&coldCounts.count, 0) + for { + oldBits := atomic.LoadUint64(&hotCounts.sumBits) + newBits := math.Float64bits(math.Float64frombits(oldBits) + sum.GetSampleSum()) + if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) { + atomic.StoreUint64(&coldCounts.sumBits, 0) + break + } + } + return nil +} + type quantSort []*dto.Quantile func (s quantSort) Len() int { diff --git a/vendor/github.com/prometheus/common/expfmt/text_create.go b/vendor/github.com/prometheus/common/expfmt/text_create.go index 16655d417c..8e473d0fe9 100644 --- a/vendor/github.com/prometheus/common/expfmt/text_create.go +++ b/vendor/github.com/prometheus/common/expfmt/text_create.go @@ -436,11 +436,11 @@ func writeEscapedString(w enhancedWriter, v string, includeDoubleQuote bool) (in func writeFloat(w enhancedWriter, f float64) (int, error) { switch { case f == 1: - return w.WriteString("1.0") + return 1, w.WriteByte('1') case f == 0: - return w.WriteString("0.0") + return 1, w.WriteByte('0') case f == -1: - return w.WriteString("-1.0") + return w.WriteString("-1") case math.IsNaN(f): return w.WriteString("NaN") case math.IsInf(f, +1): @@ -450,12 +450,6 @@ func writeFloat(w enhancedWriter, f float64) (int, error) { default: bp := numBufPool.Get().(*[]byte) *bp = strconv.AppendFloat((*bp)[:0], f, 'g', -1, 64) - // Add a .0 if used fixed point and there is no decimal - // point already. This is for future proofing with OpenMetrics, - // where floats always contain either an exponent or decimal. - if !bytes.ContainsAny(*bp, "e.") { - *bp = append(*bp, '.', '0') - } written, err := w.Write(*bp) numBufPool.Put(bp) return written, err diff --git a/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go b/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go index 648b38cb65..26e92288c7 100644 --- a/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go +++ b/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go @@ -1,12 +1,12 @@ /* +Copyright (c) 2011, Open Knowledge Foundation Ltd. +All rights reserved. + HTTP Content-Type Autonegotiation. The functions in this package implement the behaviour specified in http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html -Copyright (c) 2011, Open Knowledge Foundation Ltd. -All rights reserved. - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/vendor/github.com/prometheus/common/model/metric.go b/vendor/github.com/prometheus/common/model/metric.go index f7250909b9..00804b7fed 100644 --- a/vendor/github.com/prometheus/common/model/metric.go +++ b/vendor/github.com/prometheus/common/model/metric.go @@ -21,7 +21,6 @@ import ( ) var ( - separator = []byte{0} // MetricNameRE is a regular expression matching valid metric // names. Note that the IsValidMetricName function performs the same // check but faster than a match with this regular expression. diff --git a/vendor/github.com/prometheus/procfs/MAINTAINERS.md b/vendor/github.com/prometheus/procfs/MAINTAINERS.md index 35993c41c2..f1d3b9937b 100644 --- a/vendor/github.com/prometheus/procfs/MAINTAINERS.md +++ b/vendor/github.com/prometheus/procfs/MAINTAINERS.md @@ -1 +1,2 @@ -* Tobias Schmidt +* Tobias Schmidt @grobie +* Johannes 'fish' Ziemke @discordianfish diff --git a/vendor/github.com/prometheus/procfs/xfs/parse.go b/vendor/github.com/prometheus/procfs/xfs/parse.go index 2bc0ef3427..b3d8634df3 100644 --- a/vendor/github.com/prometheus/procfs/xfs/parse.go +++ b/vendor/github.com/prometheus/procfs/xfs/parse.go @@ -43,15 +43,15 @@ func ParseStats(r io.Reader) (*Stats, error) { fieldXpc = "xpc" // Unimplemented at this time due to lack of documentation. - fieldPushAil = "push_ail" - fieldXstrat = "xstrat" - fieldAbtb2 = "abtb2" - fieldAbtc2 = "abtc2" - fieldBmbt2 = "bmbt2" - fieldIbt2 = "ibt2" - fieldFibt2 = "fibt2" - fieldQm = "qm" - fieldDebug = "debug" + // fieldPushAil = "push_ail" + // fieldXstrat = "xstrat" + // fieldAbtb2 = "abtb2" + // fieldAbtc2 = "abtc2" + // fieldBmbt2 = "bmbt2" + // fieldIbt2 = "ibt2" + // fieldFibt2 = "fibt2" + // fieldQm = "qm" + // fieldDebug = "debug" ) var xfss Stats diff --git a/vendor/github.com/prometheus/prometheus/pkg/labels/labels.go b/vendor/github.com/prometheus/prometheus/pkg/labels/labels.go index bfc0ce5860..435f871696 100644 --- a/vendor/github.com/prometheus/prometheus/pkg/labels/labels.go +++ b/vendor/github.com/prometheus/prometheus/pkg/labels/labels.go @@ -81,6 +81,23 @@ func (ls *Labels) UnmarshalJSON(b []byte) error { return nil } +// MarshalYAML implements yaml.Marshaler. +func (ls Labels) MarshalYAML() (interface{}, error) { + return ls.Map(), nil +} + +// UnmarshalYAML implements yaml.Unmarshaler. +func (ls *Labels) UnmarshalYAML(unmarshal func(interface{}) error) error { + var m map[string]string + + if err := unmarshal(&m); err != nil { + return err + } + + *ls = FromMap(m) + return nil +} + // MatchLabels returns a subset of Labels that matches/does not match with the provided label names based on the 'on' boolean. // If on is set to true, it returns the subset of labels that match with the provided label names and its inverse when 'on' is set to false. func (ls Labels) MatchLabels(on bool, names ...string) Labels { diff --git a/vendor/github.com/prometheus/prometheus/pkg/rulefmt/rulefmt.go b/vendor/github.com/prometheus/prometheus/pkg/rulefmt/rulefmt.go index cfb2fb9856..60faee085e 100644 --- a/vendor/github.com/prometheus/prometheus/pkg/rulefmt/rulefmt.go +++ b/vendor/github.com/prometheus/prometheus/pkg/rulefmt/rulefmt.go @@ -15,16 +15,16 @@ package rulefmt import ( "context" - "fmt" "io/ioutil" "time" "github.com/pkg/errors" "github.com/prometheus/common/model" + yaml "gopkg.in/yaml.v2" + "github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/template" - "gopkg.in/yaml.v2" ) // Error represents semantical errors on parsing rule groups. @@ -174,7 +174,7 @@ func testTemplateParsing(rl *Rule) (errs []error) { for _, val := range rl.Labels { err := parseTest(val) if err != nil { - errs = append(errs, fmt.Errorf("msg=%s", err.Error())) + errs = append(errs, errors.Errorf("msg=%s", err.Error())) } } @@ -182,7 +182,7 @@ func testTemplateParsing(rl *Rule) (errs []error) { for _, val := range rl.Annotations { err := parseTest(val) if err != nil { - errs = append(errs, fmt.Errorf("msg=%s", err.Error())) + errs = append(errs, errors.Errorf("msg=%s", err.Error())) } } diff --git a/vendor/github.com/prometheus/prometheus/pkg/textparse/openmetricslex.l.go b/vendor/github.com/prometheus/prometheus/pkg/textparse/openmetricslex.l.go index 4dd7ddd73a..150d44dd05 100644 --- a/vendor/github.com/prometheus/prometheus/pkg/textparse/openmetricslex.l.go +++ b/vendor/github.com/prometheus/prometheus/pkg/textparse/openmetricslex.l.go @@ -16,7 +16,7 @@ package textparse import ( - "fmt" + "github.com/pkg/errors" ) // Lex is called by the parser generated by "go tool yacc" to obtain each @@ -33,7 +33,7 @@ yystate0: switch yyt := l.state; yyt { default: - panic(fmt.Errorf(`invalid start condition %d`, yyt)) + panic(errors.Errorf(`invalid start condition %d`, yyt)) case 0: // start condition: INITIAL goto yystart1 case 1: // start condition: sComment diff --git a/vendor/github.com/prometheus/prometheus/pkg/textparse/openmetricsparse.go b/vendor/github.com/prometheus/prometheus/pkg/textparse/openmetricsparse.go index 4598ba3066..a1b0d6977e 100644 --- a/vendor/github.com/prometheus/prometheus/pkg/textparse/openmetricsparse.go +++ b/vendor/github.com/prometheus/prometheus/pkg/textparse/openmetricsparse.go @@ -17,8 +17,6 @@ package textparse import ( - "errors" - "fmt" "io" "math" "sort" @@ -26,6 +24,8 @@ import ( "strings" "unicode/utf8" + "github.com/pkg/errors" + "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/value" ) @@ -185,7 +185,7 @@ func (p *OpenMetricsParser) Next() (Entry, error) { switch t := p.nextToken(); t { case tEofWord: if t := p.nextToken(); t != tEOF { - return EntryInvalid, fmt.Errorf("unexpected data after # EOF") + return EntryInvalid, errors.New("unexpected data after # EOF") } return EntryInvalid, io.EOF case tEOF: @@ -227,11 +227,11 @@ func (p *OpenMetricsParser) Next() (Entry, error) { case "unknown": p.mtype = MetricTypeUnknown default: - return EntryInvalid, fmt.Errorf("invalid metric type %q", s) + return EntryInvalid, errors.Errorf("invalid metric type %q", s) } case tHelp: if !utf8.Valid(p.text) { - return EntryInvalid, fmt.Errorf("help text is not a valid utf8 string") + return EntryInvalid, errors.New("help text is not a valid utf8 string") } } switch t { @@ -244,7 +244,7 @@ func (p *OpenMetricsParser) Next() (Entry, error) { u := yoloString(p.text) if len(u) > 0 { if !strings.HasSuffix(m, u) || len(m) < len(u)+1 || p.l.b[p.offsets[1]-len(u)-1] != '_' { - return EntryInvalid, fmt.Errorf("unit not a suffix of metric %q", m) + return EntryInvalid, errors.Errorf("unit not a suffix of metric %q", m) } } return EntryUnit, nil @@ -293,7 +293,7 @@ func (p *OpenMetricsParser) Next() (Entry, error) { return EntrySeries, nil default: - err = fmt.Errorf("%q %q is not a valid start token", t, string(p.l.cur())) + err = errors.Errorf("%q %q is not a valid start token", t, string(p.l.cur())) } return EntryInvalid, err } @@ -336,7 +336,7 @@ func (p *OpenMetricsParser) parseLVals() error { return parseError("expected label value", t) } if !utf8.Valid(p.l.buf()) { - return fmt.Errorf("invalid UTF-8 label value") + return errors.New("invalid UTF-8 label value") } // The openMetricsLexer ensures the value string is quoted. Strip first diff --git a/vendor/github.com/prometheus/prometheus/pkg/textparse/promlex.l.go b/vendor/github.com/prometheus/prometheus/pkg/textparse/promlex.l.go index 843feefcb1..f24f0452fd 100644 --- a/vendor/github.com/prometheus/prometheus/pkg/textparse/promlex.l.go +++ b/vendor/github.com/prometheus/prometheus/pkg/textparse/promlex.l.go @@ -16,7 +16,7 @@ package textparse import ( - "fmt" + "github.com/pkg/errors" ) const ( @@ -44,7 +44,7 @@ yystate0: switch yyt := l.state; yyt { default: - panic(fmt.Errorf(`invalid start condition %d`, yyt)) + panic(errors.Errorf(`invalid start condition %d`, yyt)) case 0: // start condition: INITIAL goto yystart1 case 1: // start condition: sComment diff --git a/vendor/github.com/prometheus/prometheus/pkg/textparse/promparse.go b/vendor/github.com/prometheus/prometheus/pkg/textparse/promparse.go index b738895982..f05b87abd3 100644 --- a/vendor/github.com/prometheus/prometheus/pkg/textparse/promparse.go +++ b/vendor/github.com/prometheus/prometheus/pkg/textparse/promparse.go @@ -17,7 +17,6 @@ package textparse import ( - "errors" "fmt" "io" "math" @@ -27,6 +26,8 @@ import ( "unicode/utf8" "unsafe" + "github.com/pkg/errors" + "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/value" ) @@ -227,9 +228,8 @@ func (p *PromParser) Metric(l *labels.Labels) string { *l = append(*l, labels.Label{Name: s[a:b], Value: s[c:d]}) } - // Sort labels. We can skip the first entry since the metric name is - // already at the right place. - sort.Sort((*l)[1:]) + // Sort labels to maintain the sorted labels invariant. + sort.Sort(*l) return s } @@ -245,7 +245,7 @@ func (p *PromParser) nextToken() token { } func parseError(exp string, got token) error { - return fmt.Errorf("%s, got %q", exp, got) + return errors.Errorf("%s, got %q", exp, got) } // Next advances the parser to the next sample. It returns false if no @@ -294,11 +294,11 @@ func (p *PromParser) Next() (Entry, error) { case "untyped": p.mtype = MetricTypeUnknown default: - return EntryInvalid, fmt.Errorf("invalid metric type %q", s) + return EntryInvalid, errors.Errorf("invalid metric type %q", s) } case tHelp: if !utf8.Valid(p.text) { - return EntryInvalid, fmt.Errorf("help text is not a valid utf8 string") + return EntryInvalid, errors.Errorf("help text is not a valid utf8 string") } } if t := p.nextToken(); t != tLinebreak { @@ -357,7 +357,7 @@ func (p *PromParser) Next() (Entry, error) { return EntrySeries, nil default: - err = fmt.Errorf("%q is not a valid start token", t) + err = errors.Errorf("%q is not a valid start token", t) } return EntryInvalid, err } @@ -381,7 +381,7 @@ func (p *PromParser) parseLVals() error { return parseError("expected label value", t) } if !utf8.Valid(p.l.buf()) { - return fmt.Errorf("invalid UTF-8 label value") + return errors.Errorf("invalid UTF-8 label value") } // The promlexer ensures the value string is quoted. Strip first diff --git a/vendor/github.com/prometheus/prometheus/promql/ast.go b/vendor/github.com/prometheus/prometheus/promql/ast.go index b427f5ee0f..e93cac2b6f 100644 --- a/vendor/github.com/prometheus/prometheus/promql/ast.go +++ b/vendor/github.com/prometheus/prometheus/promql/ast.go @@ -14,9 +14,10 @@ package promql import ( - "fmt" "time" + "github.com/pkg/errors" + "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/storage" ) @@ -301,7 +302,7 @@ func Walk(v Visitor, node Node, path []Node) error { // nothing to do default: - panic(fmt.Errorf("promql.Walk: unhandled node type %T", node)) + panic(errors.Errorf("promql.Walk: unhandled node type %T", node)) } _, err = v.Visit(nil, nil) diff --git a/vendor/github.com/prometheus/prometheus/promql/engine.go b/vendor/github.com/prometheus/prometheus/promql/engine.go index c0ab02b078..283538ccd5 100644 --- a/vendor/github.com/prometheus/prometheus/promql/engine.go +++ b/vendor/github.com/prometheus/prometheus/promql/engine.go @@ -29,14 +29,15 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" opentracing "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/pkg/gate" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/pkg/value" "github.com/prometheus/prometheus/storage" - "github.com/prometheus/prometheus/util/stats" ) @@ -181,12 +182,10 @@ func (q *query) Exec(ctx context.Context) *Result { // contextDone returns an error if the context was canceled or timed out. func contextDone(ctx context.Context, env string) error { - select { - case <-ctx.Done(): - return contextErr(ctx.Err(), env) - default: - return nil + if err := ctx.Err(); err != nil { + return contextErr(err, env) } + return nil } func contextErr(err error, env string) error { @@ -308,7 +307,7 @@ func (ng *Engine) NewRangeQuery(q storage.Queryable, qs string, start, end time. return nil, err } if expr.Type() != ValueTypeVector && expr.Type() != ValueTypeScalar { - return nil, fmt.Errorf("invalid expression type %q for range query, must be Scalar or instant Vector", documentedType(expr.Type())) + return nil, errors.Errorf("invalid expression type %q for range query, must be Scalar or instant Vector", documentedType(expr.Type())) } qry := ng.newQuery(q, expr, start, end, interval) qry.q = qs @@ -392,7 +391,7 @@ func (ng *Engine) exec(ctx context.Context, q *query) (Value, storage.Warnings, return nil, nil, s(ctx) } - panic(fmt.Errorf("promql.Engine.exec: unhandled statement of type %T", q.Statement())) + panic(errors.Errorf("promql.Engine.exec: unhandled statement of type %T", q.Statement())) } func timeMilliseconds(t time.Time) int64 { @@ -442,7 +441,7 @@ func (ng *Engine) execEvalStmt(ctx context.Context, query *query, s *EvalStmt) ( mat, ok := val.(Matrix) if !ok { - panic(fmt.Errorf("promql.Engine.exec: invalid expression type %q", val.Type())) + panic(errors.Errorf("promql.Engine.exec: invalid expression type %q", val.Type())) } query.matrix = mat switch s.Expr.Type() { @@ -460,7 +459,7 @@ func (ng *Engine) execEvalStmt(ctx context.Context, query *query, s *EvalStmt) ( case ValueTypeMatrix: return mat, warnings, nil default: - panic(fmt.Errorf("promql.Engine.exec: unexpected expression type %q", s.Expr.Type())) + panic(errors.Errorf("promql.Engine.exec: unexpected expression type %q", s.Expr.Type())) } } @@ -483,7 +482,7 @@ func (ng *Engine) execEvalStmt(ctx context.Context, query *query, s *EvalStmt) ( mat, ok := val.(Matrix) if !ok { - panic(fmt.Errorf("promql.Engine.exec: invalid expression type %q", val.Type())) + panic(errors.Errorf("promql.Engine.exec: invalid expression type %q", val.Type())) } query.matrix = mat @@ -553,6 +552,14 @@ func (ng *Engine) populateSeries(ctx context.Context, q storage.Queryable, s *Ev Step: durationToInt64Millis(s.Interval), } + // We need to make sure we select the timerange selected by the subquery. + // TODO(gouthamve): cumulativeSubqueryOffset gives the sum of range and the offset + // we can optimise it by separating out the range and offsets, and substracting the offsets + // from end also. + subqOffset := ng.cumulativeSubqueryOffset(path) + offsetMilliseconds := durationMilliseconds(subqOffset) + params.Start = params.Start - offsetMilliseconds + switch n := node.(type) { case *VectorSelector: params.Start = params.Start - durationMilliseconds(LookbackDelta) @@ -667,7 +674,7 @@ type evaluator struct { // errorf causes a panic with the input formatted into an error. func (ev *evaluator) errorf(format string, args ...interface{}) { - ev.error(fmt.Errorf(format, args...)) + ev.error(errors.Errorf(format, args...)) } // error causes a panic with the given error. @@ -687,7 +694,7 @@ func (ev *evaluator) recover(errp *error) { buf = buf[:runtime.Stack(buf, false)] level.Error(ev.logger).Log("msg", "runtime panic in parser", "err", e, "stacktrace", string(buf)) - *errp = fmt.Errorf("unexpected error: %s", err) + *errp = errors.Wrap(err, "unexpected error") } else { *errp = e.(error) } @@ -792,6 +799,9 @@ func (ev *evaluator) rangeEval(f func([]Value, *EvalNodeHelper) Vector, exprs .. seriess := make(map[uint64]Series, biggestLen) // Output series by series hash. tempNumSamples := ev.currentSamples for ts := ev.startTimestamp; ts <= ev.endTimestamp; ts += ev.interval { + if err := contextDone(ev.ctx, "expression evaluation"); err != nil { + ev.error(err) + } // Reset number of samples in memory after each timestamp. ev.currentSamples = tempNumSamples // Gather input vectors for this timestamp. @@ -1040,7 +1050,7 @@ func (ev *evaluator) eval(expr Expr) Value { case *UnaryExpr: mat := ev.eval(e.Expr).(Matrix) - if e.Op == itemSUB { + if e.Op == ItemSUB { for i := range mat { mat[i].Metric = dropMetricName(mat[i].Metric) for j := range mat[i].Points { @@ -1062,15 +1072,15 @@ func (ev *evaluator) eval(expr Expr) Value { }, e.LHS, e.RHS) case lt == ValueTypeVector && rt == ValueTypeVector: switch e.Op { - case itemLAND: + case ItemLAND: return ev.rangeEval(func(v []Value, enh *EvalNodeHelper) Vector { return ev.VectorAnd(v[0].(Vector), v[1].(Vector), e.VectorMatching, enh) }, e.LHS, e.RHS) - case itemLOR: + case ItemLOR: return ev.rangeEval(func(v []Value, enh *EvalNodeHelper) Vector { return ev.VectorOr(v[0].(Vector), v[1].(Vector), e.VectorMatching, enh) }, e.LHS, e.RHS) - case itemLUnless: + case ItemLUnless: return ev.rangeEval(func(v []Value, enh *EvalNodeHelper) Vector { return ev.VectorUnless(v[0].(Vector), v[1].(Vector), e.VectorMatching, enh) }, e.LHS, e.RHS) @@ -1128,7 +1138,7 @@ func (ev *evaluator) eval(expr Expr) Value { case *MatrixSelector: if ev.startTimestamp != ev.endTimestamp { - panic(fmt.Errorf("cannot do range evaluation of matrix selector")) + panic(errors.New("cannot do range evaluation of matrix selector")) } return ev.matrixSelector(e) @@ -1161,7 +1171,7 @@ func (ev *evaluator) eval(expr Expr) Value { return res } - panic(fmt.Errorf("unhandled expression of type: %T", expr)) + panic(errors.Errorf("unhandled expression of type: %T", expr)) } func durationToInt64Millis(d time.Duration) int64 { @@ -1579,6 +1589,11 @@ func (ev *evaluator) VectorscalarBinop(op ItemType, lhs Vector, rhs Scalar, swap lv, rv = rv, lv } value, keep := vectorElemBinop(op, lv, rv) + // Catch cases where the scalar is the LHS in a scalar-vector comparison operation. + // We want to always keep the vector element value as the output value, even if it's on the RHS. + if op.isComparisonOperator() && swap { + value = rv + } if returnBool { if keep { value = 1.0 @@ -1605,63 +1620,63 @@ func dropMetricName(l labels.Labels) labels.Labels { // scalarBinop evaluates a binary operation between two Scalars. func scalarBinop(op ItemType, lhs, rhs float64) float64 { switch op { - case itemADD: + case ItemADD: return lhs + rhs - case itemSUB: + case ItemSUB: return lhs - rhs - case itemMUL: + case ItemMUL: return lhs * rhs - case itemDIV: + case ItemDIV: return lhs / rhs - case itemPOW: + case ItemPOW: return math.Pow(lhs, rhs) - case itemMOD: + case ItemMOD: return math.Mod(lhs, rhs) - case itemEQL: + case ItemEQL: return btos(lhs == rhs) - case itemNEQ: + case ItemNEQ: return btos(lhs != rhs) - case itemGTR: + case ItemGTR: return btos(lhs > rhs) - case itemLSS: + case ItemLSS: return btos(lhs < rhs) - case itemGTE: + case ItemGTE: return btos(lhs >= rhs) - case itemLTE: + case ItemLTE: return btos(lhs <= rhs) } - panic(fmt.Errorf("operator %q not allowed for Scalar operations", op)) + panic(errors.Errorf("operator %q not allowed for Scalar operations", op)) } // vectorElemBinop evaluates a binary operation between two Vector elements. func vectorElemBinop(op ItemType, lhs, rhs float64) (float64, bool) { switch op { - case itemADD: + case ItemADD: return lhs + rhs, true - case itemSUB: + case ItemSUB: return lhs - rhs, true - case itemMUL: + case ItemMUL: return lhs * rhs, true - case itemDIV: + case ItemDIV: return lhs / rhs, true - case itemPOW: + case ItemPOW: return math.Pow(lhs, rhs), true - case itemMOD: + case ItemMOD: return math.Mod(lhs, rhs), true - case itemEQL: + case ItemEQL: return lhs, lhs == rhs - case itemNEQ: + case ItemNEQ: return lhs, lhs != rhs - case itemGTR: + case ItemGTR: return lhs, lhs > rhs - case itemLSS: + case ItemLSS: return lhs, lhs < rhs - case itemGTE: + case ItemGTE: return lhs, lhs >= rhs - case itemLTE: + case ItemLTE: return lhs, lhs <= rhs } - panic(fmt.Errorf("operator %q not allowed for operations between Vectors", op)) + panic(errors.Errorf("operator %q not allowed for operations between Vectors", op)) } type groupedAggregation struct { @@ -1678,7 +1693,7 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p result := map[uint64]*groupedAggregation{} var k int64 - if op == itemTopK || op == itemBottomK { + if op == ItemTopK || op == ItemBottomK { f := param.(float64) if !convertibleToInt64(f) { ev.errorf("Scalar value %v overflows int64", f) @@ -1689,11 +1704,11 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p } } var q float64 - if op == itemQuantile { + if op == ItemQuantile { q = param.(float64) } var valueLabel string - if op == itemCountValues { + if op == ItemCountValues { valueLabel = param.(string) if !model.LabelName(valueLabel).IsValid() { ev.errorf("invalid label name %q", valueLabel) @@ -1706,7 +1721,7 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p for _, s := range vec { metric := s.Metric - if op == itemCountValues { + if op == ItemCountValues { lb := labels.NewBuilder(metric) lb.Set(valueLabel, strconv.FormatFloat(s.V, 'f', -1, 64)) metric = lb.Labels() @@ -1754,15 +1769,15 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p if k > inputVecLen { resultSize = inputVecLen } - if op == itemStdvar || op == itemStddev { + if op == ItemStdvar || op == ItemStddev { result[groupingKey].value = 0.0 - } else if op == itemTopK || op == itemQuantile { + } else if op == ItemTopK || op == ItemQuantile { result[groupingKey].heap = make(vectorByValueHeap, 0, resultSize) heap.Push(&result[groupingKey].heap, &Sample{ Point: Point{V: s.V}, Metric: s.Metric, }) - } else if op == itemBottomK { + } else if op == ItemBottomK { result[groupingKey].reverseHeap = make(vectorByReverseValueHeap, 0, resultSize) heap.Push(&result[groupingKey].reverseHeap, &Sample{ Point: Point{V: s.V}, @@ -1773,33 +1788,33 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p } switch op { - case itemSum: + case ItemSum: group.value += s.V - case itemAvg: + case ItemAvg: group.groupCount++ group.mean += (s.V - group.mean) / float64(group.groupCount) - case itemMax: + case ItemMax: if group.value < s.V || math.IsNaN(group.value) { group.value = s.V } - case itemMin: + case ItemMin: if group.value > s.V || math.IsNaN(group.value) { group.value = s.V } - case itemCount, itemCountValues: + case ItemCount, ItemCountValues: group.groupCount++ - case itemStdvar, itemStddev: + case ItemStdvar, ItemStddev: group.groupCount++ delta := s.V - group.mean group.mean += delta / float64(group.groupCount) group.value += delta * (s.V - group.mean) - case itemTopK: + case ItemTopK: if int64(len(group.heap)) < k || group.heap[0].V < s.V || math.IsNaN(group.heap[0].V) { if int64(len(group.heap)) == k { heap.Pop(&group.heap) @@ -1810,7 +1825,7 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p }) } - case itemBottomK: + case ItemBottomK: if int64(len(group.reverseHeap)) < k || group.reverseHeap[0].V > s.V || math.IsNaN(group.reverseHeap[0].V) { if int64(len(group.reverseHeap)) == k { heap.Pop(&group.reverseHeap) @@ -1821,30 +1836,30 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p }) } - case itemQuantile: + case ItemQuantile: group.heap = append(group.heap, s) default: - panic(fmt.Errorf("expected aggregation operator but got %q", op)) + panic(errors.Errorf("expected aggregation operator but got %q", op)) } } // Construct the result Vector from the aggregated groups. for _, aggr := range result { switch op { - case itemAvg: + case ItemAvg: aggr.value = aggr.mean - case itemCount, itemCountValues: + case ItemCount, ItemCountValues: aggr.value = float64(aggr.groupCount) - case itemStdvar: + case ItemStdvar: aggr.value = aggr.value / float64(aggr.groupCount) - case itemStddev: + case ItemStddev: aggr.value = math.Sqrt(aggr.value / float64(aggr.groupCount)) - case itemTopK: + case ItemTopK: // The heap keeps the lowest value on top, so reverse it. sort.Sort(sort.Reverse(aggr.heap)) for _, v := range aggr.heap { @@ -1855,7 +1870,7 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p } continue // Bypass default append. - case itemBottomK: + case ItemBottomK: // The heap keeps the lowest value on top, so reverse it. sort.Sort(sort.Reverse(aggr.reverseHeap)) for _, v := range aggr.reverseHeap { @@ -1866,7 +1881,7 @@ func (ev *evaluator) aggregation(op ItemType, grouping []string, without bool, p } continue // Bypass default append. - case itemQuantile: + case ItemQuantile: aggr.value = quantile(q, aggr.heap) default: @@ -1893,7 +1908,7 @@ func btos(b bool) float64 { // result of the op operation. func shouldDropMetricName(op ItemType) bool { switch op { - case itemADD, itemSUB, itemDIV, itemMUL, itemMOD: + case ItemADD, ItemSUB, ItemDIV, ItemMUL, ItemPOW, ItemMOD: return true default: return false diff --git a/vendor/github.com/prometheus/prometheus/promql/functions.go b/vendor/github.com/prometheus/prometheus/promql/functions.go index baae0c3fb2..4bb3f8f436 100644 --- a/vendor/github.com/prometheus/prometheus/promql/functions.go +++ b/vendor/github.com/prometheus/prometheus/promql/functions.go @@ -14,7 +14,6 @@ package promql import ( - "fmt" "math" "regexp" "sort" @@ -22,7 +21,9 @@ import ( "strings" "time" + "github.com/pkg/errors" "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/pkg/labels" ) @@ -232,10 +233,10 @@ func funcHoltWinters(vals []Value, args Expressions, enh *EvalNodeHelper) Vector // Sanity check the input. if sf <= 0 || sf >= 1 { - panic(fmt.Errorf("invalid smoothing factor. Expected: 0 < sf < 1, got: %f", sf)) + panic(errors.Errorf("invalid smoothing factor. Expected: 0 < sf < 1, got: %f", sf)) } if tf <= 0 || tf >= 1 { - panic(fmt.Errorf("invalid trend factor. Expected: 0 < tf < 1, got: %f", tf)) + panic(errors.Errorf("invalid trend factor. Expected: 0 < tf < 1, got: %f", tf)) } var l int @@ -730,10 +731,10 @@ func funcLabelReplace(vals []Value, args Expressions, enh *EvalNodeHelper) Vecto var err error enh.regex, err = regexp.Compile("^(?:" + regexStr + ")$") if err != nil { - panic(fmt.Errorf("invalid regular expression in label_replace(): %s", regexStr)) + panic(errors.Errorf("invalid regular expression in label_replace(): %s", regexStr)) } if !model.LabelNameRE.MatchString(dst) { - panic(fmt.Errorf("invalid destination label name in label_replace(): %s", dst)) + panic(errors.Errorf("invalid destination label name in label_replace(): %s", dst)) } enh.dmn = make(map[uint64]labels.Labels, len(enh.out)) } @@ -795,13 +796,13 @@ func funcLabelJoin(vals []Value, args Expressions, enh *EvalNodeHelper) Vector { for i := 3; i < len(args); i++ { src := args[i].(*StringLiteral).Val if !model.LabelName(src).IsValid() { - panic(fmt.Errorf("invalid source label name in label_join(): %s", src)) + panic(errors.Errorf("invalid source label name in label_join(): %s", src)) } srcLabels[i-3] = src } if !model.LabelName(dst).IsValid() { - panic(fmt.Errorf("invalid destination label name in label_join(): %s", dst)) + panic(errors.Errorf("invalid destination label name in label_join(): %s", dst)) } srcVals := make([]string, len(srcLabels)) diff --git a/vendor/github.com/prometheus/prometheus/promql/lex.go b/vendor/github.com/prometheus/prometheus/promql/lex.go index 36d924a5d7..dde2799f30 100644 --- a/vendor/github.com/prometheus/prometheus/promql/lex.go +++ b/vendor/github.com/prometheus/prometheus/promql/lex.go @@ -30,11 +30,11 @@ type item struct { // String returns a descriptive string for the item. func (i item) String() string { switch { - case i.typ == itemEOF: + case i.typ == ItemEOF: return "EOF" - case i.typ == itemError: + case i.typ == ItemError: return i.val - case i.typ == itemIdentifier || i.typ == itemMetricIdentifier: + case i.typ == ItemIdentifier || i.typ == ItemMetricIdentifier: return fmt.Sprintf("%q", i.val) case i.typ.isKeyword(): return fmt.Sprintf("<%s>", i.val) @@ -59,7 +59,7 @@ func (i ItemType) isAggregator() bool { return i > aggregatorsStart && i < aggre // isAggregator returns true if the item is an aggregator that takes a parameter. // Returns false otherwise func (i ItemType) isAggregatorWithParam() bool { - return i == itemTopK || i == itemBottomK || i == itemCountValues || i == itemQuantile + return i == ItemTopK || i == ItemBottomK || i == ItemCountValues || i == ItemQuantile } // isKeyword returns true if the item corresponds to a keyword. @@ -70,7 +70,7 @@ func (i ItemType) isKeyword() bool { return i > keywordsStart && i < keywordsEnd // Returns false otherwise. func (i ItemType) isComparisonOperator() bool { switch i { - case itemEQL, itemNEQ, itemLTE, itemLSS, itemGTE, itemGTR: + case ItemEQL, ItemNEQ, ItemLTE, ItemLSS, ItemGTE, ItemGTR: return true default: return false @@ -80,7 +80,7 @@ func (i ItemType) isComparisonOperator() bool { // isSetOperator returns whether the item corresponds to a set operator. func (i ItemType) isSetOperator() bool { switch i { - case itemLAND, itemLOR, itemLUnless: + case ItemLAND, ItemLOR, ItemLUnless: return true } return false @@ -94,17 +94,17 @@ const LowestPrec = 0 // Non-operators. // is LowestPrec. func (i ItemType) precedence() int { switch i { - case itemLOR: + case ItemLOR: return 1 - case itemLAND, itemLUnless: + case ItemLAND, ItemLUnless: return 2 - case itemEQL, itemNEQ, itemLTE, itemLSS, itemGTE, itemGTR: + case ItemEQL, ItemNEQ, ItemLTE, ItemLSS, ItemGTE, ItemGTR: return 3 - case itemADD, itemSUB: + case ItemADD, ItemSUB: return 4 - case itemMUL, itemDIV, itemMOD: + case ItemMUL, ItemDIV, ItemMOD: return 5 - case itemPOW: + case ItemPOW: return 6 default: return LowestPrec @@ -113,7 +113,7 @@ func (i ItemType) precedence() int { func (i ItemType) isRightAssociative() bool { switch i { - case itemPOW: + case ItemPOW: return true default: return false @@ -124,138 +124,138 @@ func (i ItemType) isRightAssociative() bool { type ItemType int const ( - itemError ItemType = iota // Error occurred, value is error message - itemEOF - itemComment - itemIdentifier - itemMetricIdentifier - itemLeftParen - itemRightParen - itemLeftBrace - itemRightBrace - itemLeftBracket - itemRightBracket - itemComma - itemAssign - itemColon - itemSemicolon - itemString - itemNumber - itemDuration - itemBlank - itemTimes - itemSpace + ItemError ItemType = iota // Error occurred, value is error message + ItemEOF + ItemComment + ItemIdentifier + ItemMetricIdentifier + ItemLeftParen + ItemRightParen + ItemLeftBrace + ItemRightBrace + ItemLeftBracket + ItemRightBracket + ItemComma + ItemAssign + ItemColon + ItemSemicolon + ItemString + ItemNumber + ItemDuration + ItemBlank + ItemTimes + ItemSpace operatorsStart // Operators. - itemSUB - itemADD - itemMUL - itemMOD - itemDIV - itemLAND - itemLOR - itemLUnless - itemEQL - itemNEQ - itemLTE - itemLSS - itemGTE - itemGTR - itemEQLRegex - itemNEQRegex - itemPOW + ItemSUB + ItemADD + ItemMUL + ItemMOD + ItemDIV + ItemLAND + ItemLOR + ItemLUnless + ItemEQL + ItemNEQ + ItemLTE + ItemLSS + ItemGTE + ItemGTR + ItemEQLRegex + ItemNEQRegex + ItemPOW operatorsEnd aggregatorsStart // Aggregators. - itemAvg - itemCount - itemSum - itemMin - itemMax - itemStddev - itemStdvar - itemTopK - itemBottomK - itemCountValues - itemQuantile + ItemAvg + ItemCount + ItemSum + ItemMin + ItemMax + ItemStddev + ItemStdvar + ItemTopK + ItemBottomK + ItemCountValues + ItemQuantile aggregatorsEnd keywordsStart // Keywords. - itemOffset - itemBy - itemWithout - itemOn - itemIgnoring - itemGroupLeft - itemGroupRight - itemBool + ItemOffset + ItemBy + ItemWithout + ItemOn + ItemIgnoring + ItemGroupLeft + ItemGroupRight + ItemBool keywordsEnd ) var key = map[string]ItemType{ // Operators. - "and": itemLAND, - "or": itemLOR, - "unless": itemLUnless, + "and": ItemLAND, + "or": ItemLOR, + "unless": ItemLUnless, // Aggregators. - "sum": itemSum, - "avg": itemAvg, - "count": itemCount, - "min": itemMin, - "max": itemMax, - "stddev": itemStddev, - "stdvar": itemStdvar, - "topk": itemTopK, - "bottomk": itemBottomK, - "count_values": itemCountValues, - "quantile": itemQuantile, + "sum": ItemSum, + "avg": ItemAvg, + "count": ItemCount, + "min": ItemMin, + "max": ItemMax, + "stddev": ItemStddev, + "stdvar": ItemStdvar, + "topk": ItemTopK, + "bottomk": ItemBottomK, + "count_values": ItemCountValues, + "quantile": ItemQuantile, // Keywords. - "offset": itemOffset, - "by": itemBy, - "without": itemWithout, - "on": itemOn, - "ignoring": itemIgnoring, - "group_left": itemGroupLeft, - "group_right": itemGroupRight, - "bool": itemBool, + "offset": ItemOffset, + "by": ItemBy, + "without": ItemWithout, + "on": ItemOn, + "ignoring": ItemIgnoring, + "group_left": ItemGroupLeft, + "group_right": ItemGroupRight, + "bool": ItemBool, } // These are the default string representations for common items. It does not // imply that those are the only character sequences that can be lexed to such an item. var itemTypeStr = map[ItemType]string{ - itemLeftParen: "(", - itemRightParen: ")", - itemLeftBrace: "{", - itemRightBrace: "}", - itemLeftBracket: "[", - itemRightBracket: "]", - itemComma: ",", - itemAssign: "=", - itemColon: ":", - itemSemicolon: ";", - itemBlank: "_", - itemTimes: "x", - itemSpace: "", - - itemSUB: "-", - itemADD: "+", - itemMUL: "*", - itemMOD: "%", - itemDIV: "/", - itemEQL: "==", - itemNEQ: "!=", - itemLTE: "<=", - itemLSS: "<", - itemGTE: ">=", - itemGTR: ">", - itemEQLRegex: "=~", - itemNEQRegex: "!~", - itemPOW: "^", + ItemLeftParen: "(", + ItemRightParen: ")", + ItemLeftBrace: "{", + ItemRightBrace: "}", + ItemLeftBracket: "[", + ItemRightBracket: "]", + ItemComma: ",", + ItemAssign: "=", + ItemColon: ":", + ItemSemicolon: ";", + ItemBlank: "_", + ItemTimes: "x", + ItemSpace: "", + + ItemSUB: "-", + ItemADD: "+", + ItemMUL: "*", + ItemMOD: "%", + ItemDIV: "/", + ItemEQL: "==", + ItemNEQ: "!=", + ItemLTE: "<=", + ItemLSS: "<", + ItemGTE: ">=", + ItemGTR: ">", + ItemEQLRegex: "=~", + ItemNEQRegex: "!~", + ItemPOW: "^", } func init() { @@ -264,8 +264,8 @@ func init() { itemTypeStr[ty] = s } // Special numbers. - key["inf"] = itemNumber - key["nan"] = itemNumber + key["inf"] = ItemNumber + key["nan"] = ItemNumber } func (i ItemType) String() string { @@ -279,7 +279,7 @@ func (i item) desc() string { if _, ok := itemTypeStr[i.typ]; ok { return i.String() } - if i.typ == itemEOF { + if i.typ == ItemEOF { return i.typ.desc() } return fmt.Sprintf("%s %s", i.typ.desc(), i) @@ -287,21 +287,21 @@ func (i item) desc() string { func (i ItemType) desc() string { switch i { - case itemError: + case ItemError: return "error" - case itemEOF: + case ItemEOF: return "end of input" - case itemComment: + case ItemComment: return "comment" - case itemIdentifier: + case ItemIdentifier: return "identifier" - case itemMetricIdentifier: + case ItemMetricIdentifier: return "metric identifier" - case itemString: + case ItemString: return "string" - case itemNumber: + case ItemNumber: return "number" - case itemDuration: + case ItemDuration: return "duration" } return fmt.Sprintf("%q", i) @@ -408,7 +408,7 @@ func (l *lexer) linePosition() int { // errorf returns an error token and terminates the scan by passing // back a nil pointer that will be the next state, terminating l.nextItem. func (l *lexer) errorf(format string, args ...interface{}) stateFn { - l.items <- item{itemError, l.start, fmt.Sprintf(format, args...)} + l.items <- item{ItemError, l.start, fmt.Sprintf(format, args...)} return nil } @@ -463,52 +463,52 @@ func lexStatements(l *lexer) stateFn { } else if l.bracketOpen { return l.errorf("unclosed left bracket") } - l.emit(itemEOF) + l.emit(ItemEOF) return nil case r == ',': - l.emit(itemComma) + l.emit(ItemComma) case isSpace(r): return lexSpace case r == '*': - l.emit(itemMUL) + l.emit(ItemMUL) case r == '/': - l.emit(itemDIV) + l.emit(ItemDIV) case r == '%': - l.emit(itemMOD) + l.emit(ItemMOD) case r == '+': - l.emit(itemADD) + l.emit(ItemADD) case r == '-': - l.emit(itemSUB) + l.emit(ItemSUB) case r == '^': - l.emit(itemPOW) + l.emit(ItemPOW) case r == '=': if t := l.peek(); t == '=' { l.next() - l.emit(itemEQL) + l.emit(ItemEQL) } else if t == '~' { return l.errorf("unexpected character after '=': %q", t) } else { - l.emit(itemAssign) + l.emit(ItemAssign) } case r == '!': if t := l.next(); t == '=' { - l.emit(itemNEQ) + l.emit(ItemNEQ) } else { return l.errorf("unexpected character after '!': %q", t) } case r == '<': if t := l.peek(); t == '=' { l.next() - l.emit(itemLTE) + l.emit(ItemLTE) } else { - l.emit(itemLSS) + l.emit(ItemLSS) } case r == '>': if t := l.peek(); t == '=' { l.next() - l.emit(itemGTE) + l.emit(ItemGTE) } else { - l.emit(itemGTR) + l.emit(ItemGTR) } case isDigit(r) || (r == '.' && isDigit(l.peek())): l.backup() @@ -527,21 +527,21 @@ func lexStatements(l *lexer) stateFn { if l.gotColon { return l.errorf("unexpected colon %q", r) } - l.emit(itemColon) + l.emit(ItemColon) l.gotColon = true case r == '(': - l.emit(itemLeftParen) + l.emit(ItemLeftParen) l.parenDepth++ return lexStatements case r == ')': - l.emit(itemRightParen) + l.emit(ItemRightParen) l.parenDepth-- if l.parenDepth < 0 { return l.errorf("unexpected right parenthesis %q", r) } return lexStatements case r == '{': - l.emit(itemLeftBrace) + l.emit(ItemLeftBrace) l.braceOpen = true return lexInsideBraces(l) case r == '[': @@ -549,14 +549,14 @@ func lexStatements(l *lexer) stateFn { return l.errorf("unexpected left bracket %q", r) } l.gotColon = false - l.emit(itemLeftBracket) + l.emit(ItemLeftBracket) l.bracketOpen = true return lexDuration case r == ']': if !l.bracketOpen { return l.errorf("unexpected right bracket %q", r) } - l.emit(itemRightBracket) + l.emit(ItemRightBracket) l.bracketOpen = false default: @@ -581,7 +581,7 @@ func lexInsideBraces(l *lexer) stateFn { l.backup() return lexIdentifier case r == ',': - l.emit(itemComma) + l.emit(ItemComma) case r == '"' || r == '\'': l.stringOpen = r return lexString @@ -590,24 +590,24 @@ func lexInsideBraces(l *lexer) stateFn { return lexRawString case r == '=': if l.next() == '~' { - l.emit(itemEQLRegex) + l.emit(ItemEQLRegex) break } l.backup() - l.emit(itemEQL) + l.emit(ItemEQL) case r == '!': switch nr := l.next(); { case nr == '~': - l.emit(itemNEQRegex) + l.emit(ItemNEQRegex) case nr == '=': - l.emit(itemNEQ) + l.emit(ItemNEQ) default: return l.errorf("unexpected character after '!' inside braces: %q", nr) } case r == '{': return l.errorf("unexpected left brace %q", r) case r == '}': - l.emit(itemRightBrace) + l.emit(ItemRightBrace) l.braceOpen = false if l.seriesDesc { @@ -626,16 +626,16 @@ func lexValueSequence(l *lexer) stateFn { case r == eof: return lexStatements case isSpace(r): - l.emit(itemSpace) + l.emit(ItemSpace) lexSpace(l) case r == '+': - l.emit(itemADD) + l.emit(ItemADD) case r == '-': - l.emit(itemSUB) + l.emit(ItemSUB) case r == 'x': - l.emit(itemTimes) + l.emit(ItemTimes) case r == '_': - l.emit(itemBlank) + l.emit(ItemBlank) case isDigit(r) || (r == '.' && isDigit(l.peek())): l.backup() lexNumber(l) @@ -730,7 +730,7 @@ Loop: break Loop } } - l.emit(itemString) + l.emit(ItemString) return lexStatements } @@ -747,7 +747,7 @@ Loop: break Loop } } - l.emit(itemString) + l.emit(ItemString) return lexStatements } @@ -767,7 +767,7 @@ func lexLineComment(l *lexer) stateFn { r = l.next() } l.backup() - l.emit(itemComment) + l.emit(ItemComment) return lexStatements } @@ -781,7 +781,7 @@ func lexDuration(l *lexer) stateFn { return l.errorf("bad duration syntax: %q", l.input[l.start:l.pos]) } l.backup() - l.emit(itemDuration) + l.emit(ItemDuration) return lexStatements } return l.errorf("bad duration syntax: %q", l.input[l.start:l.pos]) @@ -792,14 +792,14 @@ func lexNumber(l *lexer) stateFn { if !l.scanNumber() { return l.errorf("bad number syntax: %q", l.input[l.start:l.pos]) } - l.emit(itemNumber) + l.emit(ItemNumber) return lexStatements } // lexNumberOrDuration scans a number or a duration item. func lexNumberOrDuration(l *lexer) stateFn { if l.scanNumber() { - l.emit(itemNumber) + l.emit(ItemNumber) return lexStatements } // Next two chars must be a valid unit and a non-alphanumeric. @@ -808,7 +808,7 @@ func lexNumberOrDuration(l *lexer) stateFn { return l.errorf("bad number or duration syntax: %q", l.input[l.start:l.pos]) } l.backup() - l.emit(itemDuration) + l.emit(ItemDuration) return lexStatements } return l.errorf("bad number or duration syntax: %q", l.input[l.start:l.pos]) @@ -845,7 +845,7 @@ func lexIdentifier(l *lexer) stateFn { // absorb } l.backup() - l.emit(itemIdentifier) + l.emit(ItemIdentifier) return lexStatements } @@ -864,9 +864,9 @@ Loop: if kw, ok := key[strings.ToLower(word)]; ok { l.emit(kw) } else if !strings.Contains(word, ":") { - l.emit(itemIdentifier) + l.emit(ItemIdentifier) } else { - l.emit(itemMetricIdentifier) + l.emit(ItemMetricIdentifier) } break Loop } diff --git a/vendor/github.com/prometheus/prometheus/promql/parse.go b/vendor/github.com/prometheus/prometheus/promql/parse.go index 7240452935..2a055fbbb1 100644 --- a/vendor/github.com/prometheus/prometheus/promql/parse.go +++ b/vendor/github.com/prometheus/prometheus/promql/parse.go @@ -23,10 +23,11 @@ import ( "strings" "time" + "github.com/pkg/errors" "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/value" - "github.com/prometheus/prometheus/util/strutil" ) @@ -69,7 +70,7 @@ func ParseMetric(input string) (m labels.Labels, err error) { defer p.recover(&err) m = p.metric() - if p.peek().typ != itemEOF { + if p.peek().typ != ItemEOF { p.errorf("could not parse remaining input %.15q...", p.lex.input[p.lex.lastPos:]) } return m, nil @@ -82,11 +83,11 @@ func ParseMetricSelector(input string) (m []*labels.Matcher, err error) { defer p.recover(&err) name := "" - if t := p.peek().typ; t == itemMetricIdentifier || t == itemIdentifier { + if t := p.peek().typ; t == ItemMetricIdentifier || t == ItemIdentifier { name = p.next().val } vs := p.VectorSelector(name) - if p.peek().typ != itemEOF { + if p.peek().typ != ItemEOF { p.errorf("could not parse remaining input %.15q...", p.lex.input[p.lex.lastPos:]) } return vs.LabelMatchers, nil @@ -104,8 +105,8 @@ func newParser(input string) *parser { func (p *parser) parseExpr() (expr Expr, err error) { defer p.recover(&err) - for p.peek().typ != itemEOF { - if p.peek().typ == itemComment { + for p.peek().typ != ItemEOF { + if p.peek().typ == ItemComment { continue } if expr != nil { @@ -149,20 +150,20 @@ func (p *parser) parseSeriesDesc() (m labels.Labels, vals []sequenceValue, err e const ctx = "series values" for { - for p.peek().typ == itemSpace { + for p.peek().typ == ItemSpace { p.next() } - if p.peek().typ == itemEOF { + if p.peek().typ == ItemEOF { break } // Extract blanks. - if p.peek().typ == itemBlank { + if p.peek().typ == ItemBlank { p.next() times := uint64(1) - if p.peek().typ == itemTimes { + if p.peek().typ == ItemTimes { p.next() - times, err = strconv.ParseUint(p.expect(itemNumber, ctx).val, 10, 64) + times, err = strconv.ParseUint(p.expect(ItemNumber, ctx).val, 10, 64) if err != nil { p.errorf("invalid repetition in %s: %s", ctx, err) } @@ -172,7 +173,7 @@ func (p *parser) parseSeriesDesc() (m labels.Labels, vals []sequenceValue, err e } // This is to ensure that there is a space between this and the next number. // This is especially required if the next number is negative. - if t := p.expectOneOf(itemSpace, itemEOF, ctx).typ; t == itemEOF { + if t := p.expectOneOf(ItemSpace, ItemEOF, ctx).typ; t == ItemEOF { break } continue @@ -180,15 +181,15 @@ func (p *parser) parseSeriesDesc() (m labels.Labels, vals []sequenceValue, err e // Extract values. sign := 1.0 - if t := p.peek().typ; t == itemSUB || t == itemADD { - if p.next().typ == itemSUB { + if t := p.peek().typ; t == ItemSUB || t == ItemADD { + if p.next().typ == ItemSUB { sign = -1 } } var k float64 - if t := p.peek().typ; t == itemNumber { - k = sign * p.number(p.expect(itemNumber, ctx).val) - } else if t == itemIdentifier && p.peek().val == "stale" { + if t := p.peek().typ; t == ItemNumber { + k = sign * p.number(p.expect(ItemNumber, ctx).val) + } else if t == ItemIdentifier && p.peek().val == "stale" { p.next() k = math.Float64frombits(value.StaleNaN) } else { @@ -199,24 +200,24 @@ func (p *parser) parseSeriesDesc() (m labels.Labels, vals []sequenceValue, err e }) // If there are no offset repetitions specified, proceed with the next value. - if t := p.peek(); t.typ == itemSpace { + if t := p.peek(); t.typ == ItemSpace { // This ensures there is a space between every value. continue - } else if t.typ == itemEOF { + } else if t.typ == ItemEOF { break - } else if t.typ != itemADD && t.typ != itemSUB { + } else if t.typ != ItemADD && t.typ != ItemSUB { p.errorf("expected next value or relative expansion in %s but got %s (value: %s)", ctx, t.desc(), p.peek()) } // Expand the repeated offsets into values. sign = 1.0 - if p.next().typ == itemSUB { + if p.next().typ == ItemSUB { sign = -1.0 } - offset := sign * p.number(p.expect(itemNumber, ctx).val) - p.expect(itemTimes, ctx) + offset := sign * p.number(p.expect(ItemNumber, ctx).val) + p.expect(ItemTimes, ctx) - times, err := strconv.ParseUint(p.expect(itemNumber, ctx).val, 10, 64) + times, err := strconv.ParseUint(p.expect(ItemNumber, ctx).val, 10, 64) if err != nil { p.errorf("invalid repetition in %s: %s", ctx, err) } @@ -230,7 +231,7 @@ func (p *parser) parseSeriesDesc() (m labels.Labels, vals []sequenceValue, err e // This is to ensure that there is a space between this expanding notation // and the next number. This is especially required if the next number // is negative. - if t := p.expectOneOf(itemSpace, itemEOF, ctx).typ; t == itemEOF { + if t := p.expectOneOf(ItemSpace, ItemEOF, ctx).typ; t == ItemEOF { break } } @@ -252,12 +253,12 @@ func (p *parser) next() item { } else { t := p.lex.nextItem() // Skip comments. - for t.typ == itemComment { + for t.typ == ItemComment { t = p.lex.nextItem() } p.token[0] = t } - if p.token[p.peekCount].typ == itemError { + if p.token[p.peekCount].typ == ItemError { p.errorf("%s", p.token[p.peekCount].val) } return p.token[p.peekCount] @@ -272,7 +273,7 @@ func (p *parser) peek() item { t := p.lex.nextItem() // Skip comments. - for t.typ == itemComment { + for t.typ == ItemComment { t = p.lex.nextItem() } p.token[0] = t @@ -286,7 +287,7 @@ func (p *parser) backup() { // errorf formats the error and terminates processing. func (p *parser) errorf(format string, args ...interface{}) { - p.error(fmt.Errorf(format, args...)) + p.error(errors.Errorf(format, args...)) } // error terminates processing. @@ -320,7 +321,7 @@ func (p *parser) expectOneOf(exp1, exp2 ItemType, context string) item { return token } -var errUnexpected = fmt.Errorf("unexpected error") +var errUnexpected = errors.New("unexpected error") // recover is the handler that turns panics into returns from the top level of Parse. func (p *parser) recover(errp *error) { @@ -352,11 +353,11 @@ func (p *parser) expr() Expr { op := p.peek().typ if !op.isOperator() { // Check for subquery. - if op == itemLeftBracket { + if op == ItemLeftBracket { expr = p.subqueryOrRangeSelector(expr, false) if s, ok := expr.(*SubqueryExpr); ok { // Parse optional offset. - if p.peek().typ == itemOffset { + if p.peek().typ == ItemOffset { offset := p.offset() s.Offset = offset } @@ -377,7 +378,7 @@ func (p *parser) expr() Expr { returnBool := false // Parse bool modifier. - if p.peek().typ == itemBool { + if p.peek().typ == ItemBool { if !op.isComparisonOperator() { p.errorf("bool modifier can only be used on comparison operators") } @@ -386,22 +387,22 @@ func (p *parser) expr() Expr { } // Parse ON/IGNORING clause. - if p.peek().typ == itemOn || p.peek().typ == itemIgnoring { - if p.peek().typ == itemOn { + if p.peek().typ == ItemOn || p.peek().typ == ItemIgnoring { + if p.peek().typ == ItemOn { vecMatching.On = true } p.next() vecMatching.MatchingLabels = p.labels() // Parse grouping. - if t := p.peek().typ; t == itemGroupLeft || t == itemGroupRight { + if t := p.peek().typ; t == ItemGroupLeft || t == ItemGroupRight { p.next() - if t == itemGroupLeft { + if t == ItemGroupLeft { vecMatching.Card = CardManyToOne } else { vecMatching.Card = CardOneToMany } - if p.peek().typ == itemLeftParen { + if p.peek().typ == ItemLeftParen { vecMatching.Include = p.labels() } } @@ -458,35 +459,35 @@ func (p *parser) balance(lhs Expr, op ItemType, rhs Expr, vecMatching *VectorMat // func (p *parser) unaryExpr() Expr { switch t := p.peek(); t.typ { - case itemADD, itemSUB: + case ItemADD, ItemSUB: p.next() e := p.unaryExpr() // Simplify unary expressions for number literals. if nl, ok := e.(*NumberLiteral); ok { - if t.typ == itemSUB { + if t.typ == ItemSUB { nl.Val *= -1 } return nl } return &UnaryExpr{Op: t.typ, Expr: e} - case itemLeftParen: + case ItemLeftParen: p.next() e := p.expr() - p.expect(itemRightParen, "paren expression") + p.expect(ItemRightParen, "paren expression") return &ParenExpr{Expr: e} } e := p.primaryExpr() // Expression might be followed by a range selector. - if p.peek().typ == itemLeftBracket { + if p.peek().typ == ItemLeftBracket { e = p.subqueryOrRangeSelector(e, true) } // Parse optional offset. - if p.peek().typ == itemOffset { + if p.peek().typ == ItemOffset { offset := p.offset() switch s := e.(type) { @@ -520,7 +521,7 @@ func (p *parser) subqueryOrRangeSelector(expr Expr, checkRange bool) Expr { var erange time.Duration var err error - erangeStr := p.expect(itemDuration, ctx).val + erangeStr := p.expect(ItemDuration, ctx).val erange, err = parseDuration(erangeStr) if err != nil { p.error(err) @@ -528,8 +529,8 @@ func (p *parser) subqueryOrRangeSelector(expr Expr, checkRange bool) Expr { var itm item if checkRange { - itm = p.expectOneOf(itemRightBracket, itemColon, ctx) - if itm.typ == itemRightBracket { + itm = p.expectOneOf(ItemRightBracket, ItemColon, ctx) + if itm.typ == ItemRightBracket { // Range selector. vs, ok := expr.(*VectorSelector) if !ok { @@ -542,20 +543,20 @@ func (p *parser) subqueryOrRangeSelector(expr Expr, checkRange bool) Expr { } } } else { - itm = p.expect(itemColon, ctx) + itm = p.expect(ItemColon, ctx) } // Subquery. var estep time.Duration - itm = p.expectOneOf(itemRightBracket, itemDuration, ctx) - if itm.typ == itemDuration { + itm = p.expectOneOf(ItemRightBracket, ItemDuration, ctx) + if itm.typ == ItemDuration { estepStr := itm.val estep, err = parseDuration(estepStr) if err != nil { p.error(err) } - p.expect(itemRightBracket, ctx) + p.expect(ItemRightBracket, ctx) } return &SubqueryExpr{ @@ -584,26 +585,26 @@ func (p *parser) number(val string) float64 { // func (p *parser) primaryExpr() Expr { switch t := p.next(); { - case t.typ == itemNumber: + case t.typ == ItemNumber: f := p.number(t.val) return &NumberLiteral{f} - case t.typ == itemString: + case t.typ == ItemString: return &StringLiteral{p.unquoteString(t.val)} - case t.typ == itemLeftBrace: + case t.typ == ItemLeftBrace: // Metric selector without metric name. p.backup() return p.VectorSelector("") - case t.typ == itemIdentifier: + case t.typ == ItemIdentifier: // Check for function call. - if p.peek().typ == itemLeftParen { + if p.peek().typ == ItemLeftParen { return p.call(t.val) } fallthrough // Else metric selector. - case t.typ == itemMetricIdentifier: + case t.typ == ItemMetricIdentifier: return p.VectorSelector(t.val) case t.typ.isAggregator(): @@ -623,10 +624,10 @@ func (p *parser) primaryExpr() Expr { func (p *parser) labels() []string { const ctx = "grouping opts" - p.expect(itemLeftParen, ctx) + p.expect(ItemLeftParen, ctx) labels := []string{} - if p.peek().typ != itemRightParen { + if p.peek().typ != ItemRightParen { for { id := p.next() if !isLabel(id.val) { @@ -634,13 +635,13 @@ func (p *parser) labels() []string { } labels = append(labels, id.val) - if p.peek().typ != itemComma { + if p.peek().typ != ItemComma { break } p.next() } } - p.expect(itemRightParen, ctx) + p.expect(ItemRightParen, ctx) return labels } @@ -662,8 +663,8 @@ func (p *parser) aggrExpr() *AggregateExpr { modifiersFirst := false - if t := p.peek().typ; t == itemBy || t == itemWithout { - if t == itemWithout { + if t := p.peek().typ; t == ItemBy || t == ItemWithout { + if t == ItemWithout { without = true } p.next() @@ -671,21 +672,21 @@ func (p *parser) aggrExpr() *AggregateExpr { modifiersFirst = true } - p.expect(itemLeftParen, ctx) + p.expect(ItemLeftParen, ctx) var param Expr if agop.typ.isAggregatorWithParam() { param = p.expr() - p.expect(itemComma, ctx) + p.expect(ItemComma, ctx) } e := p.expr() - p.expect(itemRightParen, ctx) + p.expect(ItemRightParen, ctx) if !modifiersFirst { - if t := p.peek().typ; t == itemBy || t == itemWithout { + if t := p.peek().typ; t == ItemBy || t == ItemWithout { if len(grouping) > 0 { p.errorf("aggregation must only contain one grouping clause") } - if t == itemWithout { + if t == ItemWithout { without = true } p.next() @@ -714,9 +715,9 @@ func (p *parser) call(name string) *Call { p.errorf("unknown function with name %q", name) } - p.expect(itemLeftParen, ctx) + p.expect(ItemLeftParen, ctx) // Might be call without args. - if p.peek().typ == itemRightParen { + if p.peek().typ == ItemRightParen { p.next() // Consume. return &Call{fn, nil} } @@ -727,14 +728,14 @@ func (p *parser) call(name string) *Call { args = append(args, e) // Terminate if no more arguments. - if p.peek().typ != itemComma { + if p.peek().typ != ItemComma { break } p.next() } // Call must be closed. - p.expect(itemRightParen, ctx) + p.expect(ItemRightParen, ctx) return &Call{Func: fn, Args: args} } @@ -745,7 +746,7 @@ func (p *parser) call(name string) *Call { // func (p *parser) labelSet() labels.Labels { set := []labels.Label{} - for _, lm := range p.labelMatchers(itemEQL) { + for _, lm := range p.labelMatchers(ItemEQL) { set = append(set, labels.Label{Name: lm.Name, Value: lm.Value}) } return labels.New(set...) @@ -760,16 +761,16 @@ func (p *parser) labelMatchers(operators ...ItemType) []*labels.Matcher { matchers := []*labels.Matcher{} - p.expect(itemLeftBrace, ctx) + p.expect(ItemLeftBrace, ctx) // Check if no matchers are provided. - if p.peek().typ == itemRightBrace { + if p.peek().typ == ItemRightBrace { p.next() return matchers } for { - label := p.expect(itemIdentifier, ctx) + label := p.expect(ItemIdentifier, ctx) op := p.next().typ if !op.isOperator() { @@ -785,18 +786,18 @@ func (p *parser) labelMatchers(operators ...ItemType) []*labels.Matcher { p.errorf("operator must be one of %q, is %q", operators, op) } - val := p.unquoteString(p.expect(itemString, ctx).val) + val := p.unquoteString(p.expect(ItemString, ctx).val) // Map the item to the respective match type. var matchType labels.MatchType switch op { - case itemEQL: + case ItemEQL: matchType = labels.MatchEqual - case itemNEQ: + case ItemNEQ: matchType = labels.MatchNotEqual - case itemEQLRegex: + case ItemEQLRegex: matchType = labels.MatchRegexp - case itemNEQRegex: + case ItemNEQRegex: matchType = labels.MatchNotRegexp default: p.errorf("item %q is not a metric match type", op) @@ -809,23 +810,23 @@ func (p *parser) labelMatchers(operators ...ItemType) []*labels.Matcher { matchers = append(matchers, m) - if p.peek().typ == itemIdentifier { + if p.peek().typ == ItemIdentifier { p.errorf("missing comma before next identifier %q", p.peek().val) } // Terminate list if last matcher. - if p.peek().typ != itemComma { + if p.peek().typ != ItemComma { break } p.next() // Allow comma after each item in a multi-line listing. - if p.peek().typ == itemRightBrace { + if p.peek().typ == ItemRightBrace { break } } - p.expect(itemRightBrace, ctx) + p.expect(ItemRightBrace, ctx) return matchers } @@ -840,14 +841,14 @@ func (p *parser) metric() labels.Labels { var m labels.Labels t := p.peek().typ - if t == itemIdentifier || t == itemMetricIdentifier { + if t == ItemIdentifier || t == ItemMetricIdentifier { name = p.next().val t = p.peek().typ } - if t != itemLeftBrace && name == "" { + if t != ItemLeftBrace && name == "" { p.errorf("missing metric name or metric selector") } - if t == itemLeftBrace { + if t == ItemLeftBrace { m = p.labelSet() } if name != "" { @@ -865,7 +866,7 @@ func (p *parser) offset() time.Duration { const ctx = "offset" p.next() - offi := p.expect(itemDuration, ctx) + offi := p.expect(ItemDuration, ctx) offset, err := parseDuration(offi.val) if err != nil { @@ -883,8 +884,8 @@ func (p *parser) offset() time.Duration { func (p *parser) VectorSelector(name string) *VectorSelector { var matchers []*labels.Matcher // Parse label matching if any. - if t := p.peek(); t.typ == itemLeftBrace { - matchers = p.labelMatchers(itemEQL, itemNEQ, itemEQLRegex, itemNEQRegex) + if t := p.peek(); t.typ == ItemLeftBrace { + matchers = p.labelMatchers(ItemEQL, ItemNEQ, ItemEQLRegex, ItemNEQRegex) } // Metric name must not be set in the label matchers and before at the same time. if name != "" { @@ -970,10 +971,10 @@ func (p *parser) checkType(node Node) (typ ValueType) { p.errorf("aggregation operator expected in aggregation expression but got %q", n.Op) } p.expectType(n.Expr, ValueTypeVector, "aggregation expression") - if n.Op == itemTopK || n.Op == itemBottomK || n.Op == itemQuantile { + if n.Op == ItemTopK || n.Op == ItemBottomK || n.Op == ItemQuantile { p.expectType(n.Param, ValueTypeScalar, "aggregation parameter") } - if n.Op == itemCountValues { + if n.Op == ItemCountValues { p.expectType(n.Param, ValueTypeString, "aggregation parameter") } @@ -1035,7 +1036,7 @@ func (p *parser) checkType(node Node) (typ ValueType) { p.checkType(n.Expr) case *UnaryExpr: - if n.Op != itemADD && n.Op != itemSUB { + if n.Op != ItemADD && n.Op != ItemSUB { p.errorf("only + and - operators allowed for unary expressions") } if t := p.checkType(n.Expr); t != ValueTypeScalar && t != ValueTypeVector { @@ -1071,7 +1072,7 @@ func parseDuration(ds string) (time.Duration, error) { return 0, err } if dur == 0 { - return 0, fmt.Errorf("duration must be greater than 0") + return 0, errors.New("duration must be greater than 0") } return time.Duration(dur), nil } diff --git a/vendor/github.com/prometheus/prometheus/promql/test.go b/vendor/github.com/prometheus/prometheus/promql/test.go index 2bd0834955..5fa7504259 100644 --- a/vendor/github.com/prometheus/prometheus/promql/test.go +++ b/vendor/github.com/prometheus/prometheus/promql/test.go @@ -15,7 +15,6 @@ package promql import ( "context" - "errors" "fmt" "io/ioutil" "math" @@ -24,6 +23,7 @@ import ( "strings" "time" + "github.com/pkg/errors" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/pkg/labels" @@ -102,7 +102,7 @@ func (t *Test) Storage() storage.Storage { func raise(line int, format string, v ...interface{}) error { return &ParseErr{ Line: line + 1, - Err: fmt.Errorf(format, v...), + Err: errors.Errorf(format, v...), } } @@ -356,21 +356,21 @@ func (ev *evalCmd) expect(pos int, m labels.Labels, vals ...sequenceValue) { func (ev *evalCmd) compareResult(result Value) error { switch val := result.(type) { case Matrix: - return fmt.Errorf("received range result on instant evaluation") + return errors.New("received range result on instant evaluation") case Vector: seen := map[uint64]bool{} for pos, v := range val { fp := v.Metric.Hash() if _, ok := ev.metrics[fp]; !ok { - return fmt.Errorf("unexpected metric %s in result", v.Metric) + return errors.Errorf("unexpected metric %s in result", v.Metric) } exp := ev.expected[fp] if ev.ordered && exp.pos != pos+1 { - return fmt.Errorf("expected metric %s with %v at position %d but was at %d", v.Metric, exp.vals, exp.pos, pos+1) + return errors.Errorf("expected metric %s with %v at position %d but was at %d", v.Metric, exp.vals, exp.pos, pos+1) } if !almostEqual(exp.vals[0].value, v.V) { - return fmt.Errorf("expected %v for %s but got %v", exp.vals[0].value, v.Metric, v.V) + return errors.Errorf("expected %v for %s but got %v", exp.vals[0].value, v.Metric, v.V) } seen[fp] = true @@ -381,17 +381,17 @@ func (ev *evalCmd) compareResult(result Value) error { for _, ss := range val { fmt.Println(" ", ss.Metric, ss.Point) } - return fmt.Errorf("expected metric %s with %v not found", ev.metrics[fp], expVals) + return errors.Errorf("expected metric %s with %v not found", ev.metrics[fp], expVals) } } case Scalar: if !almostEqual(ev.expected[0].vals[0].value, val.V) { - return fmt.Errorf("expected Scalar %v but got %v", val.V, ev.expected[0].vals[0].value) + return errors.Errorf("expected Scalar %v but got %v", val.V, ev.expected[0].vals[0].value) } default: - panic(fmt.Errorf("promql.Test.compareResult: unexpected result type %T", result)) + panic(errors.Errorf("promql.Test.compareResult: unexpected result type %T", result)) } return nil } @@ -447,16 +447,16 @@ func (t *Test) exec(tc testCommand) error { if cmd.fail { return nil } - return fmt.Errorf("error evaluating query %q (line %d): %s", cmd.expr, cmd.line, res.Err) + return errors.Wrapf(res.Err, "error evaluating query %q (line %d)", cmd.expr, cmd.line) } defer q.Close() if res.Err == nil && cmd.fail { - return fmt.Errorf("expected error evaluating query %q (line %d) but got none", cmd.expr, cmd.line) + return errors.Errorf("expected error evaluating query %q (line %d) but got none", cmd.expr, cmd.line) } err = cmd.compareResult(res.Value) if err != nil { - return fmt.Errorf("error in %s %s: %s", cmd, cmd.expr, err) + return errors.Wrapf(err, "error in %s %s", cmd, cmd.expr) } // Check query returns same result in range mode, @@ -467,7 +467,7 @@ func (t *Test) exec(tc testCommand) error { } rangeRes := q.Exec(t.context) if rangeRes.Err != nil { - return fmt.Errorf("error evaluating query %q (line %d) in range mode: %s", cmd.expr, cmd.line, rangeRes.Err) + return errors.Wrapf(rangeRes.Err, "error evaluating query %q (line %d) in range mode", cmd.expr, cmd.line) } defer q.Close() if cmd.ordered { @@ -490,7 +490,7 @@ func (t *Test) exec(tc testCommand) error { err = cmd.compareResult(vec) } if err != nil { - return fmt.Errorf("error in %s %s (line %d) rande mode: %s", cmd, cmd.expr, cmd.line, err) + return errors.Wrapf(err, "error in %s %s (line %d) rande mode", cmd, cmd.expr, cmd.line) } default: @@ -561,7 +561,7 @@ func parseNumber(s string) (float64, error) { f, err = strconv.ParseFloat(s, 64) } if err != nil { - return 0, fmt.Errorf("error parsing number: %s", err) + return 0, errors.Wrap(err, "error parsing number") } return f, nil } diff --git a/vendor/github.com/prometheus/prometheus/promql/value.go b/vendor/github.com/prometheus/prometheus/promql/value.go index fe37b403b4..5ca7c3493e 100644 --- a/vendor/github.com/prometheus/prometheus/promql/value.go +++ b/vendor/github.com/prometheus/prometheus/promql/value.go @@ -19,6 +19,8 @@ import ( "strconv" "strings" + "github.com/pkg/errors" + "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/storage" ) @@ -215,7 +217,7 @@ func (r *Result) Vector() (Vector, error) { } v, ok := r.Value.(Vector) if !ok { - return nil, fmt.Errorf("query result is not a Vector") + return nil, errors.New("query result is not a Vector") } return v, nil } @@ -228,7 +230,7 @@ func (r *Result) Matrix() (Matrix, error) { } v, ok := r.Value.(Matrix) if !ok { - return nil, fmt.Errorf("query result is not a range Vector") + return nil, errors.New("query result is not a range Vector") } return v, nil } @@ -241,7 +243,7 @@ func (r *Result) Scalar() (Scalar, error) { } v, ok := r.Value.(Scalar) if !ok { - return Scalar{}, fmt.Errorf("query result is not a Scalar") + return Scalar{}, errors.New("query result is not a Scalar") } return v, nil } diff --git a/vendor/github.com/prometheus/prometheus/template/template.go b/vendor/github.com/prometheus/prometheus/template/template.go index 7ae230063b..ef6212780f 100644 --- a/vendor/github.com/prometheus/prometheus/template/template.go +++ b/vendor/github.com/prometheus/prometheus/template/template.go @@ -16,7 +16,6 @@ package template import ( "bytes" "context" - "errors" "fmt" "math" "net/url" @@ -28,9 +27,10 @@ import ( html_template "html/template" text_template "text/template" + "github.com/pkg/errors" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" - "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/util/strutil" ) @@ -288,7 +288,7 @@ func (te Expander) Expand() (result string, resultErr error) { var ok bool resultErr, ok = r.(error) if !ok { - resultErr = fmt.Errorf("panic expanding template %v: %v", te.name, r) + resultErr = errors.Errorf("panic expanding template %v: %v", te.name, r) } } if resultErr != nil { @@ -300,12 +300,12 @@ func (te Expander) Expand() (result string, resultErr error) { tmpl, err := text_template.New(te.name).Funcs(te.funcMap).Option("missingkey=zero").Parse(te.text) if err != nil { - return "", fmt.Errorf("error parsing template %v: %v", te.name, err) + return "", errors.Wrapf(err, "error parsing template %v", te.name) } var buffer bytes.Buffer err = tmpl.Execute(&buffer, te.data) if err != nil { - return "", fmt.Errorf("error executing template %v: %v", te.name, err) + return "", errors.Wrapf(err, "error executing template %v", te.name) } return buffer.String(), nil } @@ -317,7 +317,7 @@ func (te Expander) ExpandHTML(templateFiles []string) (result string, resultErr var ok bool resultErr, ok = r.(error) if !ok { - resultErr = fmt.Errorf("panic expanding template %v: %v", te.name, r) + resultErr = errors.Errorf("panic expanding template %s: %v", te.name, r) } } }() @@ -333,18 +333,18 @@ func (te Expander) ExpandHTML(templateFiles []string) (result string, resultErr }) tmpl, err := tmpl.Parse(te.text) if err != nil { - return "", fmt.Errorf("error parsing template %v: %v", te.name, err) + return "", errors.Wrapf(err, "error parsing template %v", te.name) } if len(templateFiles) > 0 { _, err = tmpl.ParseFiles(templateFiles...) if err != nil { - return "", fmt.Errorf("error parsing template files for %v: %v", te.name, err) + return "", errors.Wrapf(err, "error parsing template files for %v", te.name) } } var buffer bytes.Buffer err = tmpl.Execute(&buffer, te.data) if err != nil { - return "", fmt.Errorf("error executing template %v: %v", te.name, err) + return "", errors.Wrapf(err, "error executing template %v", te.name) } return buffer.String(), nil } diff --git a/vendor/github.com/prometheus/tsdb/.golangci.yml b/vendor/github.com/prometheus/tsdb/.golangci.yml new file mode 100644 index 0000000000..d9efa75c7c --- /dev/null +++ b/vendor/github.com/prometheus/tsdb/.golangci.yml @@ -0,0 +1,5 @@ +# Run only staticcheck for now. Additional linters will be enabled one-by-one. +linters: + enable: + - staticcheck + disable-all: true diff --git a/vendor/github.com/prometheus/tsdb/.travis.yml b/vendor/github.com/prometheus/tsdb/.travis.yml index c146e026b6..6af68c3dee 100644 --- a/vendor/github.com/prometheus/tsdb/.travis.yml +++ b/vendor/github.com/prometheus/tsdb/.travis.yml @@ -6,8 +6,6 @@ os: - osx go: - - 1.10.x - - 1.11.x - 1.12.x go_import_path: github.com/prometheus/tsdb diff --git a/vendor/github.com/prometheus/tsdb/CHANGELOG.md b/vendor/github.com/prometheus/tsdb/CHANGELOG.md index ab222d6ded..610899d72f 100644 --- a/vendor/github.com/prometheus/tsdb/CHANGELOG.md +++ b/vendor/github.com/prometheus/tsdb/CHANGELOG.md @@ -1,5 +1,33 @@ ## master / unreleased + +## 0.8.0 + - [BUGFIX] Calling `Close` more than once on a querier returns an error instead of a panic. + - [BUGFIX] Don't panic and recover nicely when running out of disk space. + - [BUGFIX] Correctly handle empty labels. + - [BUGFIX] Don't crash on an unknown tombstone ref. + - [ENHANCEMENT] Re-add FromData function to create a chunk from bytes. It is used by Cortex and Thanos. + - [ENHANCEMENT] Simplify mergedPostings.Seek. + - [FEATURE] Added `currentSegment` metric for the current WAL segment it is being written to. + +## 0.7.1 + - [ENHANCEMENT] Reduce memory usage in mergedPostings.Seek + +## 0.7.0 + - [CHANGE] tsdb now requires golang 1.12 or higher. + - [REMOVED] `chunks.NewReader` is removed as it wasn't used anywhere. + - [REMOVED] `FromData` is considered unused so was removed. + - [FEATURE] Added option WALSegmentSize -1 to disable the WAL. + - [BUGFIX] Bugfix in selectOverlappingDirs. Only return the first overlapping blocks. + - [BUGFIX] Fsync the meta file to persist it on disk to avoid data loss in case of a host crash. + - [BUGFIX] Fix fd and vm_area leak on error path in chunks.NewDirReader. + - [BUGFIX] Fix fd and vm_area leak on error path in index.NewFileReader. + - [BUGFIX] Force persisting the tombstone file to avoid data loss in case of a host crash. + - [BUGFIX] Keep series that are still in WAL in checkpoints. + - [ENHANCEMENT] Fast path for EmptyPostings cases in Merge, Intersect and Without. + - [ENHANCEMENT] Be smarter in how we look at matchers. + - [ENHANCEMENT] PostListings and NotMatcher now public. + ## 0.6.1 - [BUGFIX] Update `last` after appending a non-overlapping chunk in `chunks.MergeOverlappingChunks`. [#539](https://github.com/prometheus/tsdb/pull/539) @@ -13,7 +41,7 @@ - Added `MergeOverlappingChunks` function in `chunks/chunks.go` to merge multiple time-overlapping Chunk Metas. - Added `MinTime` and `MaxTime` method for `BlockReader`. - [FEATURE] New `dump` command to tsdb tool to dump all samples. - - [FEATURE] New `encoding` package for common binary encoding/decoding helpers. + - [FEATURE] New `encoding` package for common binary encoding/decoding helpers. - Added to remove some code duplication. - [ENHANCEMENT] When closing the db any running compaction will be cancelled so it doesn't block. - `NewLeveledCompactor` takes a context. @@ -39,7 +67,7 @@ - [CHANGE] `LastCheckpoint()` used to return just the segment name and now it returns the full relative path. - [CHANGE] `NewSegmentsRangeReader()` can now read over miltiple wal ranges by using the new `SegmentRange{}` struct. - [CHANGE] `CorruptionErr{}` now also exposes the Segment `Dir` which is added when displaying any errors. - - [CHANGE] `Head.Init()` is changed to `Head.Init(minValidTime int64)` + - [CHANGE] `Head.Init()` is changed to `Head.Init(minValidTime int64)` - [CHANGE] `SymbolTable()` renamed to `SymbolTableSize()` to make the name consistent with the `Block{ symbolTableSize uint64 }` field. - [CHANGE] `wal.Reader{}` now exposes `Segment()` for the current segment being read and `Offset()` for the current offset. - [FEATURE] tsdbutil analyze subcomand to find churn, high cardinality, etc. diff --git a/vendor/github.com/prometheus/tsdb/Makefile b/vendor/github.com/prometheus/tsdb/Makefile index 3458e7fa49..7c35f8df2e 100644 --- a/vendor/github.com/prometheus/tsdb/Makefile +++ b/vendor/github.com/prometheus/tsdb/Makefile @@ -20,11 +20,6 @@ TSDB_BENCHMARK_OUTPUT_DIR ?= "$(TSDB_CLI_DIR)/benchout" include Makefile.common -.PHONY: deps -deps: - @echo ">> getting dependencies" - GO111MODULE=$(GO111MODULE) $(GO) get $(GOOPTS) -t ./... - build: GO111MODULE=$(GO111MODULE) $(GO) build -o $(TSDB_BIN) $(TSDB_CLI_DIR) diff --git a/vendor/github.com/prometheus/tsdb/Makefile.common b/vendor/github.com/prometheus/tsdb/Makefile.common index 7105cff023..c7f9ea64ff 100644 --- a/vendor/github.com/prometheus/tsdb/Makefile.common +++ b/vendor/github.com/prometheus/tsdb/Makefile.common @@ -60,7 +60,6 @@ $(warning Some recipes may not work as expected as the current Go runtime is '$( endif endif PROMU := $(FIRST_GOPATH)/bin/promu -STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck pkgs = ./... ifeq (arm, $(GOHOSTARCH)) @@ -70,16 +69,31 @@ else GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH) endif -PROMU_VERSION ?= 0.3.0 +PROMU_VERSION ?= 0.4.0 PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz -STATICCHECK_VERSION ?= 2019.1 -STATICCHECK_URL := https://github.com/dominikh/go-tools/releases/download/$(STATICCHECK_VERSION)/staticcheck_$(GOHOSTOS)_$(GOHOSTARCH) + +GOLANGCI_LINT := +GOLANGCI_LINT_OPTS ?= +GOLANGCI_LINT_VERSION ?= v1.16.0 +# golangci-lint only supports linux, darwin and windows platforms on i386/amd64. +# windows isn't included here because of the path separator being different. +ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) + ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) + GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint + endif +endif PREFIX ?= $(shell pwd) BIN_DIR ?= $(shell pwd) DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) DOCKER_REPO ?= prom +DOCKER_ARCHS ?= amd64 + +BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS)) +PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS)) +TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS)) + ifeq ($(GOHOSTARCH),amd64) ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows)) # Only supported on amd64 @@ -93,7 +107,7 @@ endif %: common-% ; .PHONY: common-all -common-all: precheck style check_license staticcheck unused build test +common-all: precheck style check_license lint unused build test .PHONY: common-style common-style: @@ -116,6 +130,15 @@ common-check_license: exit 1; \ fi +.PHONY: common-deps +common-deps: + @echo ">> getting dependencies" +ifdef GO111MODULE + GO111MODULE=$(GO111MODULE) $(GO) mod download +else + $(GO) get $(GOOPTS) -t ./... +endif + .PHONY: common-test-short common-test-short: @echo ">> running short tests" @@ -136,19 +159,24 @@ common-vet: @echo ">> vetting code" GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs) -.PHONY: common-staticcheck -common-staticcheck: $(STATICCHECK) - @echo ">> running staticcheck" - chmod +x $(STATICCHECK) +.PHONY: common-lint +common-lint: $(GOLANGCI_LINT) +ifdef GOLANGCI_LINT + @echo ">> running golangci-lint" ifdef GO111MODULE # 'go list' needs to be executed before staticcheck to prepopulate the modules cache. # Otherwise staticcheck might fail randomly for some reason not yet explained. GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null - GO111MODULE=$(GO111MODULE) $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) + GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs) else - $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) + $(GOLANGCI_LINT) run $(pkgs) +endif endif +# For backward-compatibility. +.PHONY: common-staticcheck +common-staticcheck: lint + .PHONY: common-unused common-unused: $(GOVENDOR) ifdef GOVENDOR @@ -178,17 +206,28 @@ common-tarball: promu @echo ">> building release tarball" $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) -.PHONY: common-docker -common-docker: - docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . - -.PHONY: common-docker-publish -common-docker-publish: - docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)" - -.PHONY: common-docker-tag-latest -common-docker-tag-latest: - docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):latest" +.PHONY: common-docker $(BUILD_DOCKER_ARCHS) +common-docker: $(BUILD_DOCKER_ARCHS) +$(BUILD_DOCKER_ARCHS): common-docker-%: + docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" \ + --build-arg ARCH="$*" \ + --build-arg OS="linux" \ + . + +.PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS) +common-docker-publish: $(PUBLISH_DOCKER_ARCHS) +$(PUBLISH_DOCKER_ARCHS): common-docker-publish-%: + docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" + +.PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS) +common-docker-tag-latest: $(TAG_DOCKER_ARCHS) +$(TAG_DOCKER_ARCHS): common-docker-tag-latest-%: + docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest" + +.PHONY: common-docker-manifest +common-docker-manifest: + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(DOCKER_IMAGE_TAG)) + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .PHONY: promu promu: $(PROMU) @@ -205,9 +244,11 @@ proto: @echo ">> generating code from proto files" @./scripts/genproto.sh -$(STATICCHECK): +ifdef GOLANGCI_LINT +$(GOLANGCI_LINT): mkdir -p $(FIRST_GOPATH)/bin - curl -s -L $(STATICCHECK_URL) > $(STATICCHECK) + curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION) +endif ifdef GOVENDOR .PHONY: $(GOVENDOR) @@ -221,7 +262,6 @@ precheck:: define PRECHECK_COMMAND_template = precheck:: $(1)_precheck - PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1))) .PHONY: $(1)_precheck $(1)_precheck: diff --git a/vendor/github.com/prometheus/tsdb/README.md b/vendor/github.com/prometheus/tsdb/README.md index 4393d511a5..c62d616d63 100644 --- a/vendor/github.com/prometheus/tsdb/README.md +++ b/vendor/github.com/prometheus/tsdb/README.md @@ -1,5 +1,6 @@ -# TSDB [![Build Status](https://travis-ci.org/prometheus/tsdb.svg?branch=master)](https://travis-ci.org/prometheus/tsdb) +# TSDB +[![Build Status](https://travis-ci.org/prometheus/tsdb.svg?branch=master)](https://travis-ci.org/prometheus/tsdb) [![GoDoc](https://godoc.org/github.com/prometheus/tsdb?status.svg)](https://godoc.org/github.com/prometheus/tsdb) [![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/tsdb)](https://goreportcard.com/report/github.com/prometheus/tsdb) diff --git a/vendor/github.com/prometheus/tsdb/block.go b/vendor/github.com/prometheus/tsdb/block.go index d9570bdd6e..1b6e79d9da 100644 --- a/vendor/github.com/prometheus/tsdb/block.go +++ b/vendor/github.com/prometheus/tsdb/block.go @@ -28,6 +28,8 @@ import ( "github.com/pkg/errors" "github.com/prometheus/tsdb/chunkenc" "github.com/prometheus/tsdb/chunks" + tsdb_errors "github.com/prometheus/tsdb/errors" + "github.com/prometheus/tsdb/fileutil" "github.com/prometheus/tsdb/index" "github.com/prometheus/tsdb/labels" ) @@ -229,12 +231,17 @@ func readMetaFile(dir string) (*BlockMeta, error) { return &m, nil } -func writeMetaFile(dir string, meta *BlockMeta) error { +func writeMetaFile(logger log.Logger, dir string, meta *BlockMeta) error { meta.Version = 1 // Make any changes to the file appear atomic. path := filepath.Join(dir, metaFilename) tmp := path + ".tmp" + defer func() { + if err := os.RemoveAll(tmp); err != nil { + level.Error(logger).Log("msg", "remove tmp file", "err", err.Error()) + } + }() f, err := os.Create(tmp) if err != nil { @@ -244,16 +251,20 @@ func writeMetaFile(dir string, meta *BlockMeta) error { enc := json.NewEncoder(f) enc.SetIndent("", "\t") - var merr MultiError - + var merr tsdb_errors.MultiError if merr.Add(enc.Encode(meta)); merr.Err() != nil { merr.Add(f.Close()) return merr.Err() } + // Force the kernel to persist the file on disk to avoid data loss if the host crashes. + if merr.Add(f.Sync()); merr.Err() != nil { + merr.Add(f.Close()) + return merr.Err() + } if err := f.Close(); err != nil { return err } - return renameFile(tmp, path) + return fileutil.Replace(tmp, path) } // Block represents a directory of time series data covering a continuous time range. @@ -272,6 +283,8 @@ type Block struct { chunkr ChunkReader indexr IndexReader tombstones TombstoneReader + + logger log.Logger } // OpenBlock opens the block in the directory. It can be passed a chunk pool, which is used @@ -283,7 +296,7 @@ func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (pb *Block, er var closers []io.Closer defer func() { if err != nil { - var merr MultiError + var merr tsdb_errors.MultiError merr.Add(err) merr.Add(closeAll(closers)) err = merr.Err() @@ -316,7 +329,7 @@ func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (pb *Block, er // that would be the logical place for a block size to be calculated. bs := blockSize(cr, ir, tsr) meta.Stats.NumBytes = bs - err = writeMetaFile(dir, meta) + err = writeMetaFile(logger, dir, meta) if err != nil { level.Warn(logger).Log("msg", "couldn't write the meta file for the block size", "block", dir, "err", err) } @@ -328,6 +341,7 @@ func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (pb *Block, er indexr: ir, tombstones: tr, symbolTableSize: ir.SymbolTableSize(), + logger: logger, } return pb, nil } @@ -350,7 +364,7 @@ func (pb *Block) Close() error { pb.pendingReaders.Wait() - var merr MultiError + var merr tsdb_errors.MultiError merr.Add(pb.chunkr.Close()) merr.Add(pb.indexr.Close()) @@ -423,7 +437,7 @@ func (pb *Block) GetSymbolTableSize() uint64 { func (pb *Block) setCompactionFailed() error { pb.meta.Compaction.Failed = true - return writeMetaFile(pb.dir, &pb.meta) + return writeMetaFile(pb.logger, pb.dir, &pb.meta) } type blockIndexReader struct { @@ -547,10 +561,10 @@ Outer: pb.tombstones = stones pb.meta.Stats.NumTombstones = pb.tombstones.Total() - if err := writeTombstoneFile(pb.dir, pb.tombstones); err != nil { + if err := writeTombstoneFile(pb.logger, pb.dir, pb.tombstones); err != nil { return err } - return writeMetaFile(pb.dir, &pb.meta) + return writeMetaFile(pb.logger, pb.dir, &pb.meta) } // CleanTombstones will remove the tombstones and rewrite the block (only if there are any tombstones). diff --git a/vendor/github.com/prometheus/tsdb/checkpoint.go b/vendor/github.com/prometheus/tsdb/checkpoint.go index 1c6239232e..d8dee28aa8 100644 --- a/vendor/github.com/prometheus/tsdb/checkpoint.go +++ b/vendor/github.com/prometheus/tsdb/checkpoint.go @@ -25,6 +25,7 @@ import ( "strings" "github.com/pkg/errors" + tsdb_errors "github.com/prometheus/tsdb/errors" "github.com/prometheus/tsdb/fileutil" "github.com/prometheus/tsdb/wal" ) @@ -67,7 +68,7 @@ func LastCheckpoint(dir string) (string, int, error) { // DeleteCheckpoints deletes all checkpoints in a directory below a given index. func DeleteCheckpoints(dir string, maxIndex int) error { - var errs MultiError + var errs tsdb_errors.MultiError files, err := ioutil.ReadDir(dir) if err != nil { diff --git a/vendor/github.com/prometheus/tsdb/chunkenc/chunk.go b/vendor/github.com/prometheus/tsdb/chunkenc/chunk.go index 12dc75403e..dc566606d5 100644 --- a/vendor/github.com/prometheus/tsdb/chunkenc/chunk.go +++ b/vendor/github.com/prometheus/tsdb/chunkenc/chunk.go @@ -48,15 +48,6 @@ type Chunk interface { NumSamples() int } -// FromData returns a chunk from a byte slice of chunk data. -func FromData(e Encoding, d []byte) (Chunk, error) { - switch e { - case EncXOR: - return &XORChunk{b: bstream{count: 0, stream: d}}, nil - } - return nil, fmt.Errorf("unknown chunk encoding: %d", e) -} - // Appender adds sample pairs to a chunk. type Appender interface { Append(int64, float64) @@ -80,16 +71,18 @@ func (nopIterator) At() (int64, float64) { return 0, 0 } func (nopIterator) Next() bool { return false } func (nopIterator) Err() error { return nil } +// Pool is used to create and reuse chunk references to avoid allocations. type Pool interface { Put(Chunk) error Get(e Encoding, b []byte) (Chunk, error) } -// Pool is a memory pool of chunk objects. +// pool is a memory pool of chunk objects. type pool struct { xor sync.Pool } +// NewPool returns a new pool. func NewPool() Pool { return &pool{ xor: sync.Pool{ @@ -129,3 +122,14 @@ func (p *pool) Put(c Chunk) error { } return nil } + +// FromData returns a chunk from a byte slice of chunk data. +// This is there so that users of the library can easily create chunks from +// bytes. +func FromData(e Encoding, d []byte) (Chunk, error) { + switch e { + case EncXOR: + return &XORChunk{b: bstream{count: 0, stream: d}}, nil + } + return nil, fmt.Errorf("unknown chunk encoding: %d", e) +} diff --git a/vendor/github.com/prometheus/tsdb/chunks/chunks.go b/vendor/github.com/prometheus/tsdb/chunks/chunks.go index dd5a5f8c26..70cb119c52 100644 --- a/vendor/github.com/prometheus/tsdb/chunks/chunks.go +++ b/vendor/github.com/prometheus/tsdb/chunks/chunks.go @@ -27,12 +27,20 @@ import ( "github.com/pkg/errors" "github.com/prometheus/tsdb/chunkenc" + tsdb_errors "github.com/prometheus/tsdb/errors" "github.com/prometheus/tsdb/fileutil" ) const ( // MagicChunks is 4 bytes at the head of a series file. MagicChunks = 0x85BD40DD + // MagicChunksSize is the size in bytes of MagicChunks. + MagicChunksSize = 4 + + chunksFormatV1 = 1 + ChunksFormatVersionSize = 1 + + chunkHeaderSize = MagicChunksSize + ChunksFormatVersionSize ) // Meta holds information about a chunk of data. @@ -57,7 +65,7 @@ func (cm *Meta) writeHash(h hash.Hash) error { return nil } -// Returns true if the chunk overlaps [mint, maxt]. +// OverlapsClosedInterval Returns true if the chunk overlaps [mint, maxt]. func (cm *Meta) OverlapsClosedInterval(mint, maxt int64) bool { // The chunk itself is a closed interval [cm.MinTime, cm.MaxTime]. return cm.MinTime <= maxt && mint <= cm.MaxTime @@ -93,8 +101,6 @@ type Writer struct { const ( defaultChunkSegmentSize = 512 * 1024 * 1024 - - chunksFormatV1 = 1 ) // NewWriter returns a new writer against the given directory. @@ -133,7 +139,7 @@ func (w *Writer) finalizeTail() error { if err := w.wbuf.Flush(); err != nil { return err } - if err := fileutil.Fsync(tf); err != nil { + if err := tf.Sync(); err != nil { return err } // As the file was pre-allocated, we truncate any superfluous zero bytes. @@ -170,9 +176,8 @@ func (w *Writer) cut() error { } // Write header metadata for new file. - metab := make([]byte, 8) - binary.BigEndian.PutUint32(metab[:4], MagicChunks) + binary.BigEndian.PutUint32(metab[:MagicChunksSize], MagicChunks) metab[4] = chunksFormatV1 if _, err := f.Write(metab); err != nil { @@ -373,27 +378,24 @@ func newReader(bs []ByteSlice, cs []io.Closer, pool chunkenc.Pool) (*Reader, err var totalSize int64 for i, b := range cr.bs { - if b.Len() < 4 { - return nil, errors.Wrapf(errInvalidSize, "validate magic in segment %d", i) + if b.Len() < chunkHeaderSize { + return nil, errors.Wrapf(errInvalidSize, "invalid chunk header in segment %d", i) } // Verify magic number. - if m := binary.BigEndian.Uint32(b.Range(0, 4)); m != MagicChunks { + if m := binary.BigEndian.Uint32(b.Range(0, MagicChunksSize)); m != MagicChunks { return nil, errors.Errorf("invalid magic number %x", m) } + + // Verify chunk format version. + if v := int(b.Range(MagicChunksSize, MagicChunksSize+ChunksFormatVersionSize)[0]); v != chunksFormatV1 { + return nil, errors.Errorf("invalid chunk format version %d", v) + } totalSize += int64(b.Len()) } cr.size = totalSize return &cr, nil } -// NewReader returns a new chunk reader against the given byte slices. -func NewReader(bs []ByteSlice, pool chunkenc.Pool) (*Reader, error) { - if pool == nil { - pool = chunkenc.NewPool() - } - return newReader(bs, nil, pool) -} - // NewDirReader returns a new Reader against sequentially numbered files in the // given directory. func NewDirReader(dir string, pool chunkenc.Pool) (*Reader, error) { @@ -406,18 +408,28 @@ func NewDirReader(dir string, pool chunkenc.Pool) (*Reader, error) { } var ( - bs []ByteSlice - cs []io.Closer + bs []ByteSlice + cs []io.Closer + merr tsdb_errors.MultiError ) for _, fn := range files { f, err := fileutil.OpenMmapFile(fn) if err != nil { - return nil, errors.Wrapf(err, "mmap files") + merr.Add(errors.Wrap(err, "mmap files")) + merr.Add(closeAll(cs)) + return nil, merr } cs = append(cs, f) bs = append(bs, realByteSlice(f.Bytes())) } - return newReader(bs, cs, pool) + + reader, err := newReader(bs, cs, pool) + if err != nil { + merr.Add(err) + merr.Add(closeAll(cs)) + return nil, merr + } + return reader, nil } func (s *Reader) Close() error { diff --git a/vendor/github.com/prometheus/tsdb/compact.go b/vendor/github.com/prometheus/tsdb/compact.go index a1a7aa76f6..c0948bbf3b 100644 --- a/vendor/github.com/prometheus/tsdb/compact.go +++ b/vendor/github.com/prometheus/tsdb/compact.go @@ -31,6 +31,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/tsdb/chunkenc" "github.com/prometheus/tsdb/chunks" + tsdb_errors "github.com/prometheus/tsdb/errors" "github.com/prometheus/tsdb/fileutil" "github.com/prometheus/tsdb/index" "github.com/prometheus/tsdb/labels" @@ -266,8 +267,8 @@ func (c *LeveledCompactor) selectDirs(ds []dirMeta) []dirMeta { return nil } -// selectOverlappingDirs returns all dirs with overlaping time ranges. -// It expects sorted input by mint. +// selectOverlappingDirs returns all dirs with overlapping time ranges. +// It expects sorted input by mint and returns the overlapping dirs in the same order as received. func (c *LeveledCompactor) selectOverlappingDirs(ds []dirMeta) []string { if len(ds) < 2 { return nil @@ -280,6 +281,8 @@ func (c *LeveledCompactor) selectOverlappingDirs(ds []dirMeta) []string { overlappingDirs = append(overlappingDirs, ds[i].dir) } overlappingDirs = append(overlappingDirs, d.dir) + } else if len(overlappingDirs) > 0 { + break } if d.meta.MaxTime > globalMaxt { globalMaxt = d.meta.MaxTime @@ -309,7 +312,7 @@ func splitByRange(ds []dirMeta, tr int64) [][]dirMeta { } // Skip blocks that don't fall into the range. This can happen via mis-alignment or // by being the multiple of the intended range. - if ds[i].meta.MinTime < t0 || ds[i].meta.MaxTime > t0+tr { + if m.MaxTime > t0+tr { i++ continue } @@ -317,7 +320,7 @@ func splitByRange(ds []dirMeta, tr int64) [][]dirMeta { // Add all dirs to the current group that are within [t0, t0+tr]. for ; i < len(ds); i++ { // Either the block falls into the next range or doesn't fit at all (checked above). - if ds[i].meta.MinTime < t0 || ds[i].meta.MaxTime > t0+tr { + if ds[i].meta.MaxTime > t0+tr { break } group = append(group, ds[i]) @@ -423,7 +426,7 @@ func (c *LeveledCompactor) Compact(dest string, dirs []string, open []*Block) (u if meta.Stats.NumSamples == 0 { for _, b := range bs { b.meta.Compaction.Deletable = true - if err = writeMetaFile(b.dir, &b.meta); err != nil { + if err = writeMetaFile(c.logger, b.dir, &b.meta); err != nil { level.Error(c.logger).Log( "msg", "Failed to write 'Deletable' to meta file after compaction", "ulid", b.meta.ULID, @@ -451,7 +454,7 @@ func (c *LeveledCompactor) Compact(dest string, dirs []string, open []*Block) (u return uid, nil } - var merr MultiError + var merr tsdb_errors.MultiError merr.Add(err) if err != context.Canceled { for _, b := range bs { @@ -529,7 +532,7 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe tmp := dir + ".tmp" var closers []io.Closer defer func(t time.Time) { - var merr MultiError + var merr tsdb_errors.MultiError merr.Add(err) merr.Add(closeAll(closers)) err = merr.Err() @@ -592,7 +595,7 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe // though these are covered under defer. This is because in Windows, // you cannot delete these unless they are closed and the defer is to // make sure they are closed if the function exits due to an error above. - var merr MultiError + var merr tsdb_errors.MultiError for _, w := range closers { merr.Add(w.Close()) } @@ -606,12 +609,12 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe return nil } - if err = writeMetaFile(tmp, meta); err != nil { + if err = writeMetaFile(c.logger, tmp, meta); err != nil { return errors.Wrap(err, "write merged meta") } // Create an empty tombstones file. - if err := writeTombstoneFile(tmp, newMemTombstones()); err != nil { + if err := writeTombstoneFile(c.logger, tmp, newMemTombstones()); err != nil { return errors.Wrap(err, "write new tombstones file") } @@ -625,7 +628,7 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe } }() - if err := fileutil.Fsync(df); err != nil { + if err := df.Sync(); err != nil { return errors.Wrap(err, "sync temporary dir file") } @@ -636,7 +639,7 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe df = nil // Block successfully written, make visible and remove old ones. - if err := renameFile(tmp, dir); err != nil { + if err := fileutil.Replace(tmp, dir); err != nil { return errors.Wrap(err, "rename block dir") } @@ -658,7 +661,7 @@ func (c *LeveledCompactor) populateBlock(blocks []BlockReader, meta *BlockMeta, overlapping bool ) defer func() { - var merr MultiError + var merr tsdb_errors.MultiError merr.Add(err) merr.Add(closeAll(closers)) err = merr.Err() @@ -1010,24 +1013,3 @@ func (c *compactionMerger) Err() error { func (c *compactionMerger) At() (labels.Labels, []chunks.Meta, Intervals) { return c.l, c.c, c.intervals } - -func renameFile(from, to string) error { - if err := os.RemoveAll(to); err != nil { - return err - } - if err := os.Rename(from, to); err != nil { - return err - } - - // Directory was renamed; sync parent dir to persist rename. - pdir, err := fileutil.OpenDir(filepath.Dir(to)) - if err != nil { - return err - } - - if err = fileutil.Fsync(pdir); err != nil { - pdir.Close() - return err - } - return pdir.Close() -} diff --git a/vendor/github.com/prometheus/tsdb/db.go b/vendor/github.com/prometheus/tsdb/db.go index 7b03a209c6..52b21c2fd1 100644 --- a/vendor/github.com/prometheus/tsdb/db.go +++ b/vendor/github.com/prometheus/tsdb/db.go @@ -15,7 +15,6 @@ package tsdb import ( - "bytes" "context" "fmt" "io" @@ -36,7 +35,9 @@ import ( "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/tsdb/chunkenc" + tsdb_errors "github.com/prometheus/tsdb/errors" "github.com/prometheus/tsdb/fileutil" + _ "github.com/prometheus/tsdb/goversion" "github.com/prometheus/tsdb/labels" "github.com/prometheus/tsdb/wal" "golang.org/x/sync/errgroup" @@ -54,7 +55,10 @@ var DefaultOptions = &Options{ // Options of the DB storage. type Options struct { - // Segments (wal files) max size + // Segments (wal files) max size. + // WALSegmentSize = 0, segment size is default size. + // WALSegmentSize > 0, segment size is WALSegmentSize. + // WALSegmentSize < 0, wal is disabled. WALSegmentSize int // Duration of persisted data to keep. @@ -92,8 +96,8 @@ type Appender interface { // If the reference is 0 it must not be used for caching. Add(l labels.Labels, t int64, v float64) (uint64, error) - // Add adds a sample pair for the referenced series. It is generally faster - // than adding a sample by providing its full label set. + // AddFast adds a sample pair for the referenced series. It is generally + // faster than adding a sample by providing its full label set. AddFast(ref uint64, t int64, v float64) error // Commit submits the collected samples and purges the batch. @@ -288,14 +292,20 @@ func Open(dir string, l log.Logger, r prometheus.Registerer, opts *Options) (db } db.compactCancel = cancel + var wlog *wal.WAL segmentSize := wal.DefaultSegmentSize - if opts.WALSegmentSize > 0 { - segmentSize = opts.WALSegmentSize - } - wlog, err := wal.NewSize(l, r, filepath.Join(dir, "wal"), segmentSize) - if err != nil { - return nil, err + // Wal is enabled. + if opts.WALSegmentSize >= 0 { + // Wal is set to a custom size. + if opts.WALSegmentSize > 0 { + segmentSize = opts.WALSegmentSize + } + wlog, err = wal.NewSize(l, r, filepath.Join(dir, "wal"), segmentSize) + if err != nil { + return nil, err + } } + db.head, err = NewHead(r, l, wlog, opts.BlockRanges[0]) if err != nil { return nil, err @@ -382,7 +392,7 @@ func (a dbAppender) Commit() error { // We could just run this check every few minutes practically. But for benchmarks // and high frequency use cases this is the safer way. - if a.db.head.MaxTime()-a.db.head.MinTime() > a.db.head.chunkRange/2*3 { + if a.db.head.compactable() { select { case a.db.compactc <- struct{}{}: default: @@ -409,13 +419,11 @@ func (db *DB) compact() (err error) { return nil default: } - // The head has a compactable range if 1.5 level 0 ranges are between the oldest - // and newest timestamp. The 0.5 acts as a buffer of the appendable window. - if db.head.MaxTime()-db.head.MinTime() <= db.opts.BlockRanges[0]/2*3 { + if !db.head.compactable() { break } mint := db.head.MinTime() - maxt := rangeForTimestamp(mint, db.opts.BlockRanges[0]) + maxt := rangeForTimestamp(mint, db.head.chunkRange) // Wrap head into a range that bounds all reads to it. head := &rangeHead{ @@ -861,7 +869,7 @@ func (db *DB) Close() error { g.Go(pb.Close) } - var merr MultiError + var merr tsdb_errors.MultiError merr.Add(g.Wait()) @@ -896,7 +904,7 @@ func (db *DB) Snapshot(dir string, withHead bool) error { if dir == db.dir { return errors.Errorf("cannot snapshot into base directory") } - if _, err := ulid.Parse(dir); err == nil { + if _, err := ulid.ParseStrict(dir); err == nil { return errors.Errorf("dir must not be a valid ULID") } @@ -1037,7 +1045,7 @@ func isBlockDir(fi os.FileInfo) bool { if !fi.IsDir() { return false } - _, err := ulid.Parse(fi.Name()) + _, err := ulid.ParseStrict(fi.Name()) return err == nil } @@ -1089,50 +1097,8 @@ func nextSequenceFile(dir string) (string, int, error) { return filepath.Join(dir, fmt.Sprintf("%0.6d", i+1)), int(i + 1), nil } -// The MultiError type implements the error interface, and contains the -// Errors used to construct it. -type MultiError []error - -// Returns a concatenated string of the contained errors -func (es MultiError) Error() string { - var buf bytes.Buffer - - if len(es) > 1 { - fmt.Fprintf(&buf, "%d errors: ", len(es)) - } - - for i, err := range es { - if i != 0 { - buf.WriteString("; ") - } - buf.WriteString(err.Error()) - } - - return buf.String() -} - -// Add adds the error to the error list if it is not nil. -func (es *MultiError) Add(err error) { - if err == nil { - return - } - if merr, ok := err.(MultiError); ok { - *es = append(*es, merr...) - } else { - *es = append(*es, err) - } -} - -// Err returns the error list as an error or nil if it is empty. -func (es MultiError) Err() error { - if len(es) == 0 { - return nil - } - return es -} - func closeAll(cs []io.Closer) error { - var merr MultiError + var merr tsdb_errors.MultiError for _, c := range cs { merr.Add(c.Close()) diff --git a/vendor/github.com/prometheus/tsdb/encoding/encoding.go b/vendor/github.com/prometheus/tsdb/encoding/encoding.go index 395e11cf8a..a732a6048e 100644 --- a/vendor/github.com/prometheus/tsdb/encoding/encoding.go +++ b/vendor/github.com/prometheus/tsdb/encoding/encoding.go @@ -27,7 +27,7 @@ var ( ErrInvalidChecksum = errors.New("invalid checksum") ) -// enbuf is a helper type to populate a byte slice with various types. +// Encbuf is a helper type to populate a byte slice with various types. type Encbuf struct { B []byte C [binary.MaxVarintLen64]byte @@ -65,14 +65,14 @@ func (e *Encbuf) PutVarint64(x int64) { e.B = append(e.B, e.C[:n]...) } -// putVarintStr writes a string to the buffer prefixed by its varint length (in bytes!). +// PutUvarintStr writes a string to the buffer prefixed by its varint length (in bytes!). func (e *Encbuf) PutUvarintStr(s string) { b := *(*[]byte)(unsafe.Pointer(&s)) e.PutUvarint(len(b)) e.PutString(s) } -// putHash appends a hash over the buffers current contents to the buffer. +// PutHash appends a hash over the buffers current contents to the buffer. func (e *Encbuf) PutHash(h hash.Hash) { h.Reset() _, err := h.Write(e.B) @@ -82,7 +82,7 @@ func (e *Encbuf) PutHash(h hash.Hash) { e.B = h.Sum(e.B) } -// decbuf provides safe methods to extract data from a byte slice. It does all +// Decbuf provides safe methods to extract data from a byte slice. It does all // necessary bounds checking and advancing of the byte slice. // Several datums can be extracted without checking for errors. However, before using // any datum, the err() method must be checked. diff --git a/vendor/github.com/prometheus/tsdb/errors/errors.go b/vendor/github.com/prometheus/tsdb/errors/errors.go new file mode 100644 index 0000000000..69d3662480 --- /dev/null +++ b/vendor/github.com/prometheus/tsdb/errors/errors.go @@ -0,0 +1,62 @@ +// Copyright 2016 The etcd Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package errors + +import ( + "bytes" + "fmt" +) + +// The MultiError type implements the error interface, and contains the +// Errors used to construct it. +type MultiError []error + +// Returns a concatenated string of the contained errors +func (es MultiError) Error() string { + var buf bytes.Buffer + + if len(es) > 1 { + fmt.Fprintf(&buf, "%d errors: ", len(es)) + } + + for i, err := range es { + if i != 0 { + buf.WriteString("; ") + } + buf.WriteString(err.Error()) + } + + return buf.String() +} + +// Add adds the error to the error list if it is not nil. +func (es *MultiError) Add(err error) { + if err == nil { + return + } + if merr, ok := err.(MultiError); ok { + *es = append(*es, merr...) + } else { + *es = append(*es, err) + } +} + +// Err returns the error list as an error or nil if it is empty. +func (es MultiError) Err() error { + if len(es) == 0 { + return nil + } + return es +} diff --git a/vendor/github.com/prometheus/tsdb/fileutil/fileutil.go b/vendor/github.com/prometheus/tsdb/fileutil/fileutil.go index 154fa18443..c55a2b81d4 100644 --- a/vendor/github.com/prometheus/tsdb/fileutil/fileutil.go +++ b/vendor/github.com/prometheus/tsdb/fileutil/fileutil.go @@ -118,7 +118,7 @@ func Rename(from, to string) error { return err } - if err = Fsync(pdir); err != nil { + if err = pdir.Sync(); err != nil { pdir.Close() return err } @@ -141,7 +141,7 @@ func Replace(from, to string) error { return err } - if err = Fsync(pdir); err != nil { + if err = pdir.Sync(); err != nil { pdir.Close() return err } diff --git a/vendor/github.com/prometheus/tsdb/fileutil/sync.go b/vendor/github.com/prometheus/tsdb/fileutil/sync.go index 54dd41f4f3..2e64a40880 100644 --- a/vendor/github.com/prometheus/tsdb/fileutil/sync.go +++ b/vendor/github.com/prometheus/tsdb/fileutil/sync.go @@ -18,11 +18,6 @@ package fileutil import "os" -// Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform. -func Fsync(f *os.File) error { - return f.Sync() -} - // Fdatasync is a wrapper around file.Sync(). Special handling is needed on linux platform. func Fdatasync(f *os.File) error { return f.Sync() diff --git a/vendor/github.com/prometheus/tsdb/fileutil/sync_darwin.go b/vendor/github.com/prometheus/tsdb/fileutil/sync_darwin.go index c2f39bf204..2af1b0f411 100644 --- a/vendor/github.com/prometheus/tsdb/fileutil/sync_darwin.go +++ b/vendor/github.com/prometheus/tsdb/fileutil/sync_darwin.go @@ -18,23 +18,10 @@ package fileutil import ( "os" - "syscall" ) -// Fsync on HFS/OSX flushes the data on to the physical drive but the drive -// may not write it to the persistent media for quite sometime and it may be -// written in out-of-order sequence. Using F_FULLFSYNC ensures that the -// physical drive's buffer will also get flushed to the media. -func Fsync(f *os.File) error { - _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_FULLFSYNC), uintptr(0)) - if errno == 0 { - return nil - } - return errno -} - // Fdatasync on darwin platform invokes fcntl(F_FULLFSYNC) for actual persistence // on physical drive media. func Fdatasync(f *os.File) error { - return Fsync(f) + return f.Sync() } diff --git a/vendor/github.com/prometheus/tsdb/fileutil/sync_linux.go b/vendor/github.com/prometheus/tsdb/fileutil/sync_linux.go index 1bbced915e..8b4fc8268e 100644 --- a/vendor/github.com/prometheus/tsdb/fileutil/sync_linux.go +++ b/vendor/github.com/prometheus/tsdb/fileutil/sync_linux.go @@ -21,11 +21,6 @@ import ( "syscall" ) -// Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform. -func Fsync(f *os.File) error { - return f.Sync() -} - // Fdatasync is similar to fsync(), but does not flush modified metadata // unless that metadata is needed in order to allow a subsequent data retrieval // to be correctly handled. diff --git a/vendor/github.com/prometheus/tsdb/go.mod b/vendor/github.com/prometheus/tsdb/go.mod index df0015df3a..02f3cf9e78 100644 --- a/vendor/github.com/prometheus/tsdb/go.mod +++ b/vendor/github.com/prometheus/tsdb/go.mod @@ -18,7 +18,7 @@ require ( github.com/pkg/errors v0.8.0 github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v0.9.1 - github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 + github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce // indirect github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d // indirect github.com/stretchr/testify v1.2.2 // indirect diff --git a/vendor/github.com/prometheus/tsdb/goversion/goversion.go b/vendor/github.com/prometheus/tsdb/goversion/goversion.go new file mode 100644 index 0000000000..8b194d4a2b --- /dev/null +++ b/vendor/github.com/prometheus/tsdb/goversion/goversion.go @@ -0,0 +1,19 @@ +// Copyright 2017 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build go1.12 + +// Package goversion enforces the go version suported by the tsdb module. +package goversion + +const _SoftwareRequiresGOVERSION1_12 = uint8(0) diff --git a/vendor/github.com/prometheus/tsdb/goversion/init.go b/vendor/github.com/prometheus/tsdb/goversion/init.go new file mode 100644 index 0000000000..dd15e1f7af --- /dev/null +++ b/vendor/github.com/prometheus/tsdb/goversion/init.go @@ -0,0 +1,17 @@ +// Copyright 2017 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package goversion + +// This will fail to compile if the Go runtime version isn't >= 1.12. +var _ = _SoftwareRequiresGOVERSION1_12 diff --git a/vendor/github.com/prometheus/tsdb/head.go b/vendor/github.com/prometheus/tsdb/head.go index fe2089754c..92619a6401 100644 --- a/vendor/github.com/prometheus/tsdb/head.go +++ b/vendor/github.com/prometheus/tsdb/head.go @@ -39,7 +39,7 @@ var ( ErrNotFound = errors.Errorf("not found") // ErrOutOfOrderSample is returned if an appended sample has a - // timestamp larger than the most recent sample. + // timestamp smaller than the most recent sample. ErrOutOfOrderSample = errors.New("out of order sample") // ErrAmendSample is returned if an appended sample has the same timestamp @@ -75,6 +75,9 @@ type Head struct { symbols map[string]struct{} values map[string]stringset // label names to possible values + deletedMtx sync.Mutex + deleted map[uint64]int // Deleted series, and what WAL segment they must be kept until. + postings *index.MemPostings // postings lists for terms } @@ -234,6 +237,7 @@ func NewHead(r prometheus.Registerer, l log.Logger, wal *wal.WAL, chunkRange int values: map[string]stringset{}, symbols: map[string]struct{}{}, postings: index.NewUnorderedMemPostings(), + deleted: map[uint64]int{}, } h.metrics = newHeadMetrics(h, r) @@ -417,6 +421,10 @@ func (h *Head) loadWAL(r *wal.Reader) error { if itv.Maxt < h.minValidTime { continue } + if m := h.series.getByID(s.ref); m == nil { + unknownRefs++ + continue + } allStones.addInterval(s.ref, itv) } } @@ -557,7 +565,13 @@ func (h *Head) Truncate(mint int64) (err error) { } keep := func(id uint64) bool { - return h.series.getByID(id) != nil + if h.series.getByID(id) != nil { + return true + } + h.deletedMtx.Lock() + _, ok := h.deleted[id] + h.deletedMtx.Unlock() + return ok } h.metrics.checkpointCreationTotal.Inc() if _, err = Checkpoint(h.wal, first, last, keep, mint); err != nil { @@ -570,6 +584,17 @@ func (h *Head) Truncate(mint int64) (err error) { // that supersedes them. level.Error(h.logger).Log("msg", "truncating segments failed", "err", err) } + + // The checkpoint is written and segments before it is truncated, so we no + // longer need to track deleted series that are before it. + h.deletedMtx.Lock() + for ref, segment := range h.deleted { + if segment < first { + delete(h.deleted, ref) + } + } + h.deletedMtx.Unlock() + h.metrics.checkpointDeleteTotal.Inc() if err := DeleteCheckpoints(h.wal.Dir(), last); err != nil { // Leftover old checkpoints do not cause problems down the line beyond @@ -734,6 +759,9 @@ func (a *headAppender) Add(lset labels.Labels, t int64, v float64) (uint64, erro return 0, ErrOutOfBounds } + // Ensure no empty labels have gotten through. + lset = lset.WithoutEmpty() + s, created := a.head.getOrCreate(lset.Hash(), lset) if created { a.series = append(a.series, RefSeries{ @@ -891,8 +919,8 @@ func (h *Head) Delete(mint, maxt int64, ms ...labels.Matcher) error { var enc RecordEncoder if h.wal != nil { // Although we don't store the stones in the head - // we need to write them to the WAL to mark these as deleted - // after a restart while loeading the WAL. + // we need to write them to the WAL to mark these as deleted + // after a restart while loading the WAL. if err := h.wal.Log(enc.Tombstones(stones, nil)); err != nil { return err } @@ -953,8 +981,23 @@ func (h *Head) gc() { // Remove deleted series IDs from the postings lists. h.postings.Delete(deleted) + if h.wal != nil { + _, last, _ := h.wal.Segments() + h.deletedMtx.Lock() + // Keep series records until we're past segment 'last' + // because the WAL will still have samples records with + // this ref ID. If we didn't keep these series records then + // on start up when we replay the WAL, or any other code + // that reads the WAL, wouldn't be able to use those + // samples since we would have no labels for that ref ID. + for ref := range deleted { + h.deleted[ref] = last + } + h.deletedMtx.Unlock() + } + // Rebuild symbols and label value indices from what is left in the postings terms. - symbols := make(map[string]struct{}) + symbols := make(map[string]struct{}, len(h.symbols)) values := make(map[string]stringset, len(h.values)) if err := h.postings.Iter(func(t labels.Label, _ index.Postings) error { @@ -1020,6 +1063,13 @@ func (h *Head) MaxTime() int64 { return atomic.LoadInt64(&h.maxTime) } +// compactable returns whether the head has a compactable range. +// The head has a compactable range when the head time range is 1.5 times the chunk range. +// The 0.5 acts as a buffer of the appendable window. +func (h *Head) compactable() bool { + return h.MaxTime()-h.MinTime() > h.chunkRange/2*3 +} + // Close flushes the WAL and closes the head. func (h *Head) Close() error { if h.wal == nil { diff --git a/vendor/github.com/prometheus/tsdb/index/index.go b/vendor/github.com/prometheus/tsdb/index/index.go index 580291a717..6b333fa584 100644 --- a/vendor/github.com/prometheus/tsdb/index/index.go +++ b/vendor/github.com/prometheus/tsdb/index/index.go @@ -29,6 +29,7 @@ import ( "github.com/pkg/errors" "github.com/prometheus/tsdb/chunks" "github.com/prometheus/tsdb/encoding" + tsdb_errors "github.com/prometheus/tsdb/errors" "github.com/prometheus/tsdb/fileutil" "github.com/prometheus/tsdb/labels" ) @@ -52,7 +53,6 @@ const ( type indexWriterSeries struct { labels labels.Labels chunks []chunks.Meta // series file offset of chunks - offset uint32 // index file offset of series reference } type indexWriterSeriesSlice []*indexWriterSeries @@ -192,7 +192,7 @@ func NewWriter(fn string) (*Writer, error) { if err != nil { return nil, err } - if err := fileutil.Fsync(df); err != nil { + if err := df.Sync(); err != nil { return nil, errors.Wrap(err, "sync dir") } @@ -554,7 +554,7 @@ func (w *Writer) Close() error { if err := w.fbuf.Flush(); err != nil { return err } - if err := fileutil.Fsync(w.f); err != nil { + if err := w.f.Sync(); err != nil { return err } return w.f.Close() @@ -625,7 +625,15 @@ func NewFileReader(path string) (*Reader, error) { if err != nil { return nil, err } - return newReader(realByteSlice(f.Bytes()), f) + r, err := newReader(realByteSlice(f.Bytes()), f) + if err != nil { + var merr tsdb_errors.MultiError + merr.Add(err) + merr.Add(f.Close()) + return nil, merr + } + + return r, nil } func newReader(b ByteSlice, c io.Closer) (*Reader, error) { diff --git a/vendor/github.com/prometheus/tsdb/index/postings.go b/vendor/github.com/prometheus/tsdb/index/postings.go index cbad5b74d1..bb7b5837af 100644 --- a/vendor/github.com/prometheus/tsdb/index/postings.go +++ b/vendor/github.com/prometheus/tsdb/index/postings.go @@ -92,7 +92,7 @@ func (p *MemPostings) Get(name, value string) Postings { if lp == nil { return EmptyPostings() } - return newListPostings(lp) + return newListPostings(lp...) } // All returns a postings list over all documents ever added. @@ -202,7 +202,7 @@ func (p *MemPostings) Iter(f func(labels.Label, Postings) error) error { for n, e := range p.m { for v, p := range e { - if err := f(labels.Label{Name: n, Value: v}, newListPostings(p)); err != nil { + if err := f(labels.Label{Name: n, Value: v}, newListPostings(p...)); err != nil { return err } } @@ -283,6 +283,8 @@ func (e errPostings) Err() error { return e.err } var emptyPostings = errPostings{} // EmptyPostings returns a postings list that's always empty. +// NOTE: Returning EmptyPostings sentinel when index.Postings struct has no postings is recommended. +// It triggers optimized flow in other functions like Intersect, Without etc. func EmptyPostings() Postings { return emptyPostings } @@ -296,13 +298,20 @@ func ErrPostings(err error) Postings { // input postings. func Intersect(its ...Postings) Postings { if len(its) == 0 { - return emptyPostings + return EmptyPostings() } if len(its) == 1 { return its[0] } + l := len(its) / 2 - return newIntersectPostings(Intersect(its[:l]...), Intersect(its[l:]...)) + a := Intersect(its[:l]...) + b := Intersect(its[l:]...) + + if a == EmptyPostings() || b == EmptyPostings() { + return EmptyPostings() + } + return newIntersectPostings(a, b) } type intersectPostings struct { @@ -366,7 +375,12 @@ func Merge(its ...Postings) Postings { if len(its) == 1 { return its[0] } - return newMergedPostings(its) + + p, ok := newMergedPostings(its) + if !ok { + return EmptyPostings() + } + return p } type postingsHeap []Postings @@ -390,23 +404,28 @@ func (h *postingsHeap) Pop() interface{} { type mergedPostings struct { h postingsHeap initilized bool - heaped bool cur uint64 err error } -func newMergedPostings(p []Postings) *mergedPostings { +func newMergedPostings(p []Postings) (m *mergedPostings, nonEmpty bool) { ph := make(postingsHeap, 0, len(p)) + for _, it := range p { + // NOTE: mergedPostings struct requires the user to issue an initial Next. if it.Next() { ph = append(ph, it) } else { if it.Err() != nil { - return &mergedPostings{err: it.Err()} + return &mergedPostings{err: it.Err()}, true } } } - return &mergedPostings{h: ph} + + if len(ph) == 0 { + return nil, false + } + return &mergedPostings{h: ph}, true } func (it *mergedPostings) Next() bool { @@ -414,12 +433,9 @@ func (it *mergedPostings) Next() bool { return false } - if !it.heaped { - heap.Init(&it.h) - it.heaped = true - } // The user must issue an initial Next. if !it.initilized { + heap.Init(&it.h) it.cur = it.h[0].At() it.initilized = true return true @@ -457,32 +473,24 @@ func (it *mergedPostings) Seek(id uint64) bool { return false } } - if it.cur >= id { - return true - } - // Heapifying when there is lots of Seeks is inefficient, - // mark to be re-heapified on the Next() call. - it.heaped = false - newH := make(postingsHeap, 0, len(it.h)) - lowest := ^uint64(0) - for _, i := range it.h { - if i.Seek(id) { - newH = append(newH, i) - if i.At() < lowest { - lowest = i.At() + for it.cur < id { + cur := it.h[0] + if !cur.Seek(id) { + heap.Pop(&it.h) + if cur.Err() != nil { + it.err = cur.Err() + return false } - } else { - if i.Err() != nil { - it.err = i.Err() + if it.h.Len() == 0 { return false } + } else { + // Value of top of heap has changed, re-heapify. + heap.Fix(&it.h, 0) } + + it.cur = it.h[0].At() } - it.h = newH - if len(it.h) == 0 { - return false - } - it.cur = lowest return true } @@ -495,8 +503,15 @@ func (it mergedPostings) Err() error { } // Without returns a new postings list that contains all elements from the full list that -// are not in the drop list +// are not in the drop list. func Without(full, drop Postings) Postings { + if full == EmptyPostings() { + return EmptyPostings() + } + + if drop == EmptyPostings() { + return full + } return newRemovedPostings(full, drop) } @@ -573,25 +588,25 @@ func (rp *removedPostings) Err() error { return rp.remove.Err() } -// listPostings implements the Postings interface over a plain list. -type listPostings struct { +// ListPostings implements the Postings interface over a plain list. +type ListPostings struct { list []uint64 cur uint64 } func NewListPostings(list []uint64) Postings { - return newListPostings(list) + return newListPostings(list...) } -func newListPostings(list []uint64) *listPostings { - return &listPostings{list: list} +func newListPostings(list ...uint64) *ListPostings { + return &ListPostings{list: list} } -func (it *listPostings) At() uint64 { +func (it *ListPostings) At() uint64 { return it.cur } -func (it *listPostings) Next() bool { +func (it *ListPostings) Next() bool { if len(it.list) > 0 { it.cur = it.list[0] it.list = it.list[1:] @@ -601,7 +616,7 @@ func (it *listPostings) Next() bool { return false } -func (it *listPostings) Seek(x uint64) bool { +func (it *ListPostings) Seek(x uint64) bool { // If the current value satisfies, then return. if it.cur >= x { return true @@ -623,7 +638,7 @@ func (it *listPostings) Seek(x uint64) bool { return false } -func (it *listPostings) Err() error { +func (it *ListPostings) Err() error { return nil } diff --git a/vendor/github.com/prometheus/tsdb/labels/labels.go b/vendor/github.com/prometheus/tsdb/labels/labels.go index d1ba70b454..aab8e42be9 100644 --- a/vendor/github.com/prometheus/tsdb/labels/labels.go +++ b/vendor/github.com/prometheus/tsdb/labels/labels.go @@ -103,6 +103,23 @@ func (ls Labels) Map() map[string]string { return m } +// WithoutEmpty returns the labelset without empty labels. +// May return the same labelset. +func (ls Labels) WithoutEmpty() Labels { + for _, v := range ls { + if v.Value == "" { + els := make(Labels, 0, len(ls)-1) + for _, v := range ls { + if v.Value != "" { + els = append(els, v) + } + } + return els + } + } + return ls +} + // New returns a sorted Labels from the given labels. // The caller has to guarantee that all label names are unique. func New(ls ...Label) Labels { @@ -119,7 +136,9 @@ func New(ls ...Label) Labels { func FromMap(m map[string]string) Labels { l := make(Labels, 0, len(m)) for k, v := range m { - l = append(l, Label{Name: k, Value: v}) + if v != "" { + l = append(l, Label{Name: k, Value: v}) + } } sort.Sort(l) @@ -133,7 +152,9 @@ func FromStrings(ss ...string) Labels { } var res Labels for i := 0; i < len(ss); i += 2 { - res = append(res, Label{Name: ss[i], Value: ss[i+1]}) + if ss[i+1] != "" { + res = append(res, Label{Name: ss[i], Value: ss[i+1]}) + } } sort.Sort(res) @@ -204,9 +225,7 @@ func ReadLabels(fn string, n int) ([]Labels, error) { hashes[h] = struct{}{} i++ } - if err != nil { - return nil, err - } + if i != n { return mets, errors.Errorf("requested %d metrics but found %d", n, i) } diff --git a/vendor/github.com/prometheus/tsdb/labels/selector.go b/vendor/github.com/prometheus/tsdb/labels/selector.go index c0c74ed526..a0565f57e3 100644 --- a/vendor/github.com/prometheus/tsdb/labels/selector.go +++ b/vendor/github.com/prometheus/tsdb/labels/selector.go @@ -14,6 +14,7 @@ package labels import ( + "fmt" "regexp" ) @@ -36,6 +37,8 @@ type Matcher interface { Name() string // Matches checks whether a value fulfills the constraints. Matches(v string) bool + // String returns a human readable matcher. + String() string } // EqualMatcher matches on equality. @@ -44,13 +47,16 @@ type EqualMatcher struct { } // Name implements Matcher interface. -func (m *EqualMatcher) Name() string { return m.name } +func (m EqualMatcher) Name() string { return m.name } // Matches implements Matcher interface. -func (m *EqualMatcher) Matches(v string) bool { return v == m.value } +func (m EqualMatcher) Matches(v string) bool { return v == m.value } + +// String implements Matcher interface. +func (m EqualMatcher) String() string { return fmt.Sprintf("%s=%q", m.name, m.value) } // Value returns the matched value. -func (m *EqualMatcher) Value() string { return m.value } +func (m EqualMatcher) Value() string { return m.value } // NewEqualMatcher returns a new matcher matching an exact label value. func NewEqualMatcher(name, value string) Matcher { @@ -62,8 +68,9 @@ type regexpMatcher struct { re *regexp.Regexp } -func (m *regexpMatcher) Name() string { return m.name } -func (m *regexpMatcher) Matches(v string) bool { return m.re.MatchString(v) } +func (m regexpMatcher) Name() string { return m.name } +func (m regexpMatcher) Matches(v string) bool { return m.re.MatchString(v) } +func (m regexpMatcher) String() string { return fmt.Sprintf("%s=~%q", m.name, m.re.String()) } // NewRegexpMatcher returns a new matcher verifying that a value matches // the regular expression pattern. @@ -75,7 +82,7 @@ func NewRegexpMatcher(name, pattern string) (Matcher, error) { return ®expMatcher{name: name, re: re}, nil } -// NewRegexpMatcher returns a new matcher verifying that a value matches +// NewMustRegexpMatcher returns a new matcher verifying that a value matches // the regular expression pattern. Will panic if the pattern is not a valid // regular expression. func NewMustRegexpMatcher(name, pattern string) Matcher { @@ -87,14 +94,15 @@ func NewMustRegexpMatcher(name, pattern string) Matcher { } -// notMatcher inverts the matching result for a matcher. -type notMatcher struct { +// NotMatcher inverts the matching result for a matcher. +type NotMatcher struct { Matcher } -func (m *notMatcher) Matches(v string) bool { return !m.Matcher.Matches(v) } +func (m NotMatcher) Matches(v string) bool { return !m.Matcher.Matches(v) } +func (m NotMatcher) String() string { return fmt.Sprintf("not(%s)", m.Matcher.String()) } // Not inverts the matcher's matching result. func Not(m Matcher) Matcher { - return ¬Matcher{m} + return &NotMatcher{m} } diff --git a/vendor/github.com/prometheus/tsdb/querier.go b/vendor/github.com/prometheus/tsdb/querier.go index 3e8cd77ca5..9d99de0837 100644 --- a/vendor/github.com/prometheus/tsdb/querier.go +++ b/vendor/github.com/prometheus/tsdb/querier.go @@ -21,6 +21,7 @@ import ( "github.com/pkg/errors" "github.com/prometheus/tsdb/chunkenc" "github.com/prometheus/tsdb/chunks" + tsdb_errors "github.com/prometheus/tsdb/errors" "github.com/prometheus/tsdb/index" "github.com/prometheus/tsdb/labels" ) @@ -134,7 +135,7 @@ func (q *querier) sel(qs []Querier, ms []labels.Matcher) (SeriesSet, error) { } func (q *querier) Close() error { - var merr MultiError + var merr tsdb_errors.MultiError for _, bq := range q.blocks { merr.Add(bq.Close()) @@ -204,6 +205,8 @@ type blockQuerier struct { chunks ChunkReader tombstones TombstoneReader + closed bool + mint, maxt int64 } @@ -251,46 +254,96 @@ func (q *blockQuerier) LabelValuesFor(string, labels.Label) ([]string, error) { } func (q *blockQuerier) Close() error { - var merr MultiError + if q.closed { + return errors.New("block querier already closed") + } + var merr tsdb_errors.MultiError merr.Add(q.index.Close()) merr.Add(q.chunks.Close()) merr.Add(q.tombstones.Close()) - + q.closed = true return merr.Err() } // PostingsForMatchers assembles a single postings iterator against the index reader -// based on the given matchers. It returns a list of label names that must be manually -// checked to not exist in series the postings list points to. +// based on the given matchers. func PostingsForMatchers(ix IndexReader, ms ...labels.Matcher) (index.Postings, error) { - var its []index.Postings + var its, notIts []index.Postings + // See which label must be non-empty. + labelMustBeSet := make(map[string]bool, len(ms)) + for _, m := range ms { + if !m.Matches("") { + labelMustBeSet[m.Name()] = true + } + } for _, m := range ms { - it, err := postingsForMatcher(ix, m) + matchesEmpty := m.Matches("") + if labelMustBeSet[m.Name()] || !matchesEmpty { + // If this matcher must be non-empty, we can be smarter. + nm, isNot := m.(*labels.NotMatcher) + if isNot && matchesEmpty { // l!="foo" + // If the label can't be empty and is a Not and the inner matcher + // doesn't match empty, then subtract it out at the end. + it, err := postingsForMatcher(ix, nm.Matcher) + if err != nil { + return nil, err + } + notIts = append(notIts, it) + } else if isNot && !matchesEmpty { // l!="" + // If the label can't be empty and is a Not, but the inner matcher can + // be empty we need to use inversePostingsForMatcher. + it, err := inversePostingsForMatcher(ix, nm.Matcher) + if err != nil { + return nil, err + } + its = append(its, it) + } else { // l="a" + // Non-Not matcher, use normal postingsForMatcher. + it, err := postingsForMatcher(ix, m) + if err != nil { + return nil, err + } + its = append(its, it) + } + } else { // l="" + // If the matchers for a labelname selects an empty value, it selects all + // the series which don't have the label name set too. See: + // https://github.com/prometheus/prometheus/issues/3575 and + // https://github.com/prometheus/prometheus/pull/3578#issuecomment-351653555 + it, err := inversePostingsForMatcher(ix, m) + if err != nil { + return nil, err + } + notIts = append(notIts, it) + } + } + + // If there's nothing to subtract from, add in everything and remove the notIts later. + if len(its) == 0 && len(notIts) != 0 { + allPostings, err := ix.Postings(index.AllPostingsKey()) if err != nil { return nil, err } - its = append(its, it) + its = append(its, allPostings) } - return ix.SortedPostings(index.Intersect(its...)), nil + + it := index.Intersect(its...) + + for _, n := range notIts { + it = index.Without(it, n) + } + + return ix.SortedPostings(it), nil } func postingsForMatcher(ix IndexReader, m labels.Matcher) (index.Postings, error) { - // If the matcher selects an empty value, it selects all the series which don't - // have the label name set too. See: https://github.com/prometheus/prometheus/issues/3575 - // and https://github.com/prometheus/prometheus/pull/3578#issuecomment-351653555 - if m.Matches("") { - return postingsForUnsetLabelMatcher(ix, m) - } + // This method will not return postings for missing labels. // Fast-path for equal matching. if em, ok := m.(*labels.EqualMatcher); ok { - it, err := ix.Postings(em.Name(), em.Value()) - if err != nil { - return nil, err - } - return it, nil + return ix.Postings(em.Name(), em.Value()) } tpls, err := ix.LabelValues(m.Name()) @@ -326,7 +379,8 @@ func postingsForMatcher(ix IndexReader, m labels.Matcher) (index.Postings, error return index.Merge(rit...), nil } -func postingsForUnsetLabelMatcher(ix IndexReader, m labels.Matcher) (index.Postings, error) { +// inversePostingsForMatcher eeturns the postings for the series with the label name set but not matching the matcher. +func inversePostingsForMatcher(ix IndexReader, m labels.Matcher) (index.Postings, error) { tpls, err := ix.LabelValues(m.Name()) if err != nil { return nil, err @@ -354,23 +408,7 @@ func postingsForUnsetLabelMatcher(ix IndexReader, m labels.Matcher) (index.Posti rit = append(rit, it) } - merged := index.Merge(rit...) - // With many many postings, it's best to pre-calculate - // the merged list via next rather than have a ton of seeks - // in Without/Intersection. - if len(rit) > 100 { - pl, err := index.ExpandPostings(merged) - if err != nil { - return nil, err - } - merged = index.NewListPostings(pl) - } - - allPostings, err := ix.Postings(index.AllPostingsKey()) - if err != nil { - return nil, err - } - return index.Without(allPostings, merged), nil + return index.Merge(rit...), nil } func mergeStrings(a, b []string) []string { diff --git a/vendor/github.com/prometheus/tsdb/repair.go b/vendor/github.com/prometheus/tsdb/repair.go index 4aeffb5547..38138b12a5 100644 --- a/vendor/github.com/prometheus/tsdb/repair.go +++ b/vendor/github.com/prometheus/tsdb/repair.go @@ -23,6 +23,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/pkg/errors" + tsdb_errors "github.com/prometheus/tsdb/errors" "github.com/prometheus/tsdb/fileutil" ) @@ -39,6 +40,16 @@ func repairBadIndexVersion(logger log.Logger, dir string) error { wrapErr := func(err error, d string) error { return errors.Wrapf(err, "block dir: %q", d) } + + tmpFiles := make([]string, 0, len(dir)) + defer func() { + for _, tmp := range tmpFiles { + if err := os.RemoveAll(tmp); err != nil { + level.Error(logger).Log("msg", "remove tmp file", "err", err.Error()) + } + } + }() + for _, d := range dirs { meta, err := readBogusMetaFile(d) if err != nil { @@ -64,6 +75,8 @@ func repairBadIndexVersion(logger log.Logger, dir string) error { if err != nil { return wrapErr(err, d) } + tmpFiles = append(tmpFiles, repl.Name()) + broken, err := os.Open(filepath.Join(d, indexFilename)) if err != nil { return wrapErr(err, d) @@ -71,12 +84,19 @@ func repairBadIndexVersion(logger log.Logger, dir string) error { if _, err := io.Copy(repl, broken); err != nil { return wrapErr(err, d) } + + var merr tsdb_errors.MultiError + // Set the 5th byte to 2 to indicate the correct file format version. if _, err := repl.WriteAt([]byte{2}, 4); err != nil { - return wrapErr(err, d) + merr.Add(wrapErr(err, d)) + merr.Add(wrapErr(repl.Close(), d)) + return merr.Err() } - if err := fileutil.Fsync(repl); err != nil { - return wrapErr(err, d) + if err := repl.Sync(); err != nil { + merr.Add(wrapErr(err, d)) + merr.Add(wrapErr(repl.Close(), d)) + return merr.Err() } if err := repl.Close(); err != nil { return wrapErr(err, d) @@ -84,12 +104,12 @@ func repairBadIndexVersion(logger log.Logger, dir string) error { if err := broken.Close(); err != nil { return wrapErr(err, d) } - if err := renameFile(repl.Name(), broken.Name()); err != nil { + if err := fileutil.Replace(repl.Name(), broken.Name()); err != nil { return wrapErr(err, d) } // Reset version of meta.json to 1. meta.Version = 1 - if err := writeMetaFile(d, meta); err != nil { + if err := writeMetaFile(logger, d, meta); err != nil { return wrapErr(err, d) } } diff --git a/vendor/github.com/prometheus/tsdb/tombstones.go b/vendor/github.com/prometheus/tsdb/tombstones.go index 4c36c7b2a4..220af49007 100644 --- a/vendor/github.com/prometheus/tsdb/tombstones.go +++ b/vendor/github.com/prometheus/tsdb/tombstones.go @@ -22,8 +22,12 @@ import ( "path/filepath" "sync" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" "github.com/pkg/errors" "github.com/prometheus/tsdb/encoding" + tsdb_errors "github.com/prometheus/tsdb/errors" + "github.com/prometheus/tsdb/fileutil" ) const tombstoneFilename = "tombstones" @@ -50,7 +54,7 @@ type TombstoneReader interface { Close() error } -func writeTombstoneFile(dir string, tr TombstoneReader) error { +func writeTombstoneFile(logger log.Logger, dir string, tr TombstoneReader) error { path := filepath.Join(dir, tombstoneFilename) tmp := path + ".tmp" hash := newCRC32() @@ -61,7 +65,12 @@ func writeTombstoneFile(dir string, tr TombstoneReader) error { } defer func() { if f != nil { - f.Close() + if err := f.Close(); err != nil { + level.Error(logger).Log("msg", "close tmp file", "err", err.Error()) + } + } + if err := os.RemoveAll(tmp); err != nil { + level.Error(logger).Log("msg", "remove tmp file", "err", err.Error()) } }() @@ -100,11 +109,17 @@ func writeTombstoneFile(dir string, tr TombstoneReader) error { return err } + var merr tsdb_errors.MultiError + if merr.Add(f.Sync()); merr.Err() != nil { + merr.Add(f.Close()) + return merr.Err() + } + if err = f.Close(); err != nil { return err } f = nil - return renameFile(tmp, path) + return fileutil.Replace(tmp, path) } // Stone holds the information on the posting and time-range diff --git a/vendor/github.com/prometheus/tsdb/wal.go b/vendor/github.com/prometheus/tsdb/wal.go index d7ffe0c1ef..86b3bf79cd 100644 --- a/vendor/github.com/prometheus/tsdb/wal.go +++ b/vendor/github.com/prometheus/tsdb/wal.go @@ -338,6 +338,12 @@ func (w *SegmentWAL) Truncate(mint int64, keep func(uint64) bool) error { if err != nil { return errors.Wrap(err, "create compaction segment") } + defer func() { + if err := os.RemoveAll(f.Name()); err != nil { + level.Error(w.logger).Log("msg", "remove tmp file", "err", err.Error()) + } + }() + var ( csf = newSegmentFile(f) crc32 = newCRC32() @@ -389,7 +395,7 @@ func (w *SegmentWAL) Truncate(mint int64, keep func(uint64) bool) error { csf.Close() candidates[0].Close() // need close before remove on platform windows - if err := renameFile(csf.Name(), candidates[0].Name()); err != nil { + if err := fileutil.Replace(csf.Name(), candidates[0].Name()); err != nil { return errors.Wrap(err, "rename compaction segment") } for _, f := range candidates[1:] { diff --git a/vendor/github.com/prometheus/tsdb/wal/wal.go b/vendor/github.com/prometheus/tsdb/wal/wal.go index b37032604e..46504f0d97 100644 --- a/vendor/github.com/prometheus/tsdb/wal/wal.go +++ b/vendor/github.com/prometheus/tsdb/wal/wal.go @@ -159,9 +159,9 @@ type WAL struct { logger log.Logger segmentSize int mtx sync.RWMutex - segment *Segment // active segment - donePages int // pages written to the segment - page *page // active page + segment *Segment // Active segment. + donePages int // Pages written to the segment. + page *page // Active page. stopc chan chan struct{} actorc chan func() closed bool // To allow calling Close() more than once without blocking. @@ -171,6 +171,7 @@ type WAL struct { pageCompletions prometheus.Counter truncateFail prometheus.Counter truncateTotal prometheus.Counter + currentSegment prometheus.Gauge } // New returns a new WAL over the given directory. @@ -218,8 +219,12 @@ func NewSize(logger log.Logger, reg prometheus.Registerer, dir string, segmentSi Name: "prometheus_tsdb_wal_truncations_total", Help: "Total number of WAL truncations attempted.", }) + w.currentSegment = prometheus.NewGauge(prometheus.GaugeOpts{ + Name: "prometheus_tsdb_wal_segment_current", + Help: "WAL segment index that TSDB is currently writing to.", + }) if reg != nil { - reg.MustRegister(w.fsyncDuration, w.pageFlushes, w.pageCompletions, w.truncateFail, w.truncateTotal) + reg.MustRegister(w.fsyncDuration, w.pageFlushes, w.pageCompletions, w.truncateFail, w.truncateTotal, w.currentSegment) } _, j, err := w.Segments() @@ -413,7 +418,7 @@ func (w *WAL) setSegment(segment *Segment) error { return err } w.donePages = int(stat.Size() / pageSize) - + w.currentSegment.Set(float64(segment.Index())) return nil } @@ -426,10 +431,10 @@ func (w *WAL) flushPage(clear bool) error { p := w.page clear = clear || p.full() - // No more data will fit into the page. Enqueue and clear it. + // No more data will fit into the page or an implicit clear. + // Enqueue and clear it. if clear { p.alloc = pageSize // Write till end of page. - w.pageCompletions.Inc() } n, err := w.segment.Write(p.buf[p.flushed:p.alloc]) if err != nil { @@ -445,6 +450,7 @@ func (w *WAL) flushPage(clear bool) error { p.alloc = 0 p.flushed = 0 w.donePages++ + w.pageCompletions.Inc() } return nil } @@ -495,10 +501,18 @@ func (w *WAL) Log(recs ...[]byte) error { return nil } -// log writes rec to the log and forces a flush of the current page if its -// the final record of a batch, the record is bigger than the page size or -// the current page is full. +// log writes rec to the log and forces a flush of the current page if: +// - the final record of a batch +// - the record is bigger than the page size +// - the current page is full. func (w *WAL) log(rec []byte, final bool) error { + // When the last page flush failed the page will remain full. + // When the page is full, need to flush it before trying to add more records to it. + if w.page.full() { + if err := w.flushPage(true); err != nil { + return err + } + } // If the record is too big to fit within the active page in the current // segment, terminate the active segment and advance to the next one. // This ensures that records do not cross segment boundaries. @@ -595,7 +609,7 @@ func (w *WAL) Truncate(i int) (err error) { func (w *WAL) fsync(f *Segment) error { start := time.Now() - err := fileutil.Fsync(f.File) + err := f.File.Sync() w.fsyncDuration.Observe(time.Since(start).Seconds()) return err } @@ -606,7 +620,7 @@ func (w *WAL) Close() (err error) { defer w.mtx.Unlock() if w.closed { - return nil + return errors.New("wal already closed") } // Flush the last page and zero out all its remaining size. diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index 4ec0792eb5..c0c80d8930 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -28,6 +28,7 @@ import ( "strconv" "strings" "sync" + "sync/atomic" "time" "golang.org/x/net/http/httpguts" @@ -199,6 +200,7 @@ type ClientConn struct { t *Transport tconn net.Conn // usually *tls.Conn, except specialized impls tlsState *tls.ConnectionState // nil only for specialized impls + reused uint32 // whether conn is being reused; atomic singleUse bool // whether being used for a single http.Request // readLoop goroutine fields: @@ -440,7 +442,8 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err) return nil, err } - traceGotConn(req, cc) + reused := !atomic.CompareAndSwapUint32(&cc.reused, 0, 1) + traceGotConn(req, cc, reused) res, gotErrAfterReqBodyWrite, err := cc.roundTrip(req) if err != nil && retry <= 6 { if req, err = shouldRetryRequest(req, err, gotErrAfterReqBodyWrite); err == nil { @@ -2559,15 +2562,15 @@ func traceGetConn(req *http.Request, hostPort string) { trace.GetConn(hostPort) } -func traceGotConn(req *http.Request, cc *ClientConn) { +func traceGotConn(req *http.Request, cc *ClientConn, reused bool) { trace := httptrace.ContextClientTrace(req.Context()) if trace == nil || trace.GotConn == nil { return } ci := httptrace.GotConnInfo{Conn: cc.tconn} + ci.Reused = reused cc.mu.Lock() - ci.Reused = cc.nextStreamID > 1 - ci.WasIdle = len(cc.streams) == 0 && ci.Reused + ci.WasIdle = len(cc.streams) == 0 && reused if ci.WasIdle && !cc.lastActive.IsZero() { ci.IdleTime = time.Now().Sub(cc.lastActive) } diff --git a/vendor/gopkg.in/inf.v0/dec.go b/vendor/gopkg.in/inf.v0/dec.go index 3b4afedf1a..26548b63ce 100644 --- a/vendor/gopkg.in/inf.v0/dec.go +++ b/vendor/gopkg.in/inf.v0/dec.go @@ -104,7 +104,7 @@ var bigInt = [...]*big.Int{ var exp10cache [64]big.Int = func() [64]big.Int { e10, e10i := [64]big.Int{}, bigInt[1] - for i, _ := range e10 { + for i := range e10 { e10[i].Set(e10i) e10i = new(big.Int).Mul(e10i, bigInt[10]) } diff --git a/vendor/modules.txt b/vendor/modules.txt index c1f063ba0f..bf9d057592 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -49,7 +49,7 @@ github.com/go-openapi/swag # github.com/gogo/protobuf v1.2.1 github.com/gogo/protobuf/proto github.com/gogo/protobuf/sortkeys -# github.com/golang/protobuf v1.2.0 +# github.com/golang/protobuf v1.3.1 github.com/golang/protobuf/proto github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes @@ -68,7 +68,7 @@ github.com/hashicorp/golang-lru github.com/hashicorp/golang-lru/simplelru # github.com/imdario/mergo v0.3.5 github.com/imdario/mergo -# github.com/improbable-eng/thanos v0.4.0 +# github.com/improbable-eng/thanos v0.5.0 github.com/improbable-eng/thanos/pkg/reloader github.com/improbable-eng/thanos/pkg/runutil # github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3 @@ -109,23 +109,23 @@ github.com/opentracing/opentracing-go/log github.com/pkg/errors # github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib/difflib -# github.com/prometheus/client_golang v0.9.2 +# github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus/promhttp github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/promauto -# github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 +# github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f github.com/prometheus/client_model/go -# github.com/prometheus/common v0.0.0-20181218105931-67670fe90761 +# github.com/prometheus/common v0.4.0 github.com/prometheus/common/expfmt github.com/prometheus/common/model github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg -# github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a +# github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 github.com/prometheus/procfs github.com/prometheus/procfs/nfs github.com/prometheus/procfs/xfs github.com/prometheus/procfs/internal/util -# github.com/prometheus/prometheus v0.0.0-20190328180107-4d60eb36dcbe +# github.com/prometheus/prometheus v2.9.2+incompatible github.com/prometheus/prometheus/pkg/rulefmt github.com/prometheus/prometheus/pkg/timestamp github.com/prometheus/prometheus/promql @@ -139,23 +139,25 @@ github.com/prometheus/prometheus/util/stats github.com/prometheus/prometheus/util/strutil github.com/prometheus/prometheus/util/testutil github.com/prometheus/prometheus/storage/tsdb -# github.com/prometheus/tsdb v0.6.1 +# github.com/prometheus/tsdb v0.8.0 +github.com/prometheus/tsdb/errors github.com/prometheus/tsdb +github.com/prometheus/tsdb/labels github.com/prometheus/tsdb/chunkenc github.com/prometheus/tsdb/chunks github.com/prometheus/tsdb/encoding github.com/prometheus/tsdb/fileutil +github.com/prometheus/tsdb/goversion github.com/prometheus/tsdb/index -github.com/prometheus/tsdb/labels github.com/prometheus/tsdb/wal # github.com/spf13/pflag v1.0.3 github.com/spf13/pflag # github.com/stretchr/testify v1.3.0 github.com/stretchr/testify/require github.com/stretchr/testify/assert -# golang.org/x/crypto v0.0.0-20190424203555-c05e17bb3b2d +# golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f golang.org/x/crypto/ssh/terminal -# golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6 +# golang.org/x/net v0.0.0-20190522155817-f3200d17e092 golang.org/x/net/http2 golang.org/x/net/context golang.org/x/net/http/httpguts @@ -199,7 +201,7 @@ google.golang.org/appengine/internal/log google.golang.org/appengine/internal/remote_api # gopkg.in/alecthomas/kingpin.v2 v2.2.6 gopkg.in/alecthomas/kingpin.v2 -# gopkg.in/inf.v0 v0.9.0 +# gopkg.in/inf.v0 v0.9.1 gopkg.in/inf.v0 # gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v2