Skip to content

Commit 22629b3

Browse files
authored
Update Vendored Deps (#47)
* update vendored dependencies and fix issues Signed-off-by: Jacob Lisi <[email protected]> * update vendor changes after rebase Signed-off-by: Jacob Lisi <[email protected]> * fix lint issues Signed-off-by: Jacob Lisi <[email protected]> * correctly fix linting error Signed-off-by: Jacob Lisi <[email protected]>
1 parent f105f5c commit 22629b3

File tree

3,129 files changed

+444994
-388531
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,129 files changed

+444994
-388531
lines changed

go.mod

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
module github.com/grafana/cortextool
22

3-
go 1.12
4-
5-
replace github.com/hashicorp/consul => github.com/hashicorp/consul v1.5.1
3+
go 1.13
64

75
require (
8-
cloud.google.com/go v0.44.1
6+
cloud.google.com/go/bigtable v1.2.0
7+
cloud.google.com/go/storage v1.6.0
98
github.com/alecthomas/chroma v0.7.0
109
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect
11-
github.com/cortexproject/cortex v0.4.0
10+
github.com/cortexproject/cortex v1.1.1-0.20200605125619-1406f60579d5
1211
github.com/dlclark/regexp2 v1.2.0 // indirect
13-
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48
12+
github.com/gogo/protobuf v1.3.1
1413
github.com/golang/snappy v0.0.1
15-
github.com/jpillora/backoff v1.0.0 // indirect
16-
github.com/mattn/go-isatty v0.0.9 // indirect
1714
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
18-
github.com/opentracing/opentracing-go v1.1.0
19-
github.com/pkg/errors v0.8.1
15+
github.com/opentracing/opentracing-go v1.1.1-0.20200124165624-2876d2018785
16+
github.com/pkg/errors v0.9.1
2017
github.com/prometheus/alertmanager v0.20.0
21-
github.com/prometheus/client_golang v1.3.0
22-
github.com/prometheus/common v0.7.0
23-
github.com/prometheus/prometheus v1.8.2-0.20190918104050-8744afdd1ea0
24-
github.com/sirupsen/logrus v1.4.2
25-
github.com/stretchr/testify v1.4.0
26-
google.golang.org/api v0.8.0
18+
github.com/prometheus/client_golang v1.6.0
19+
github.com/prometheus/common v0.10.0
20+
github.com/prometheus/prometheus v1.8.2-0.20200605084833-6ff4814a492a
21+
github.com/sirupsen/logrus v1.5.0
22+
github.com/stretchr/testify v1.5.1
23+
google.golang.org/api v0.26.0
2724
gopkg.in/alecthomas/kingpin.v2 v2.2.6
28-
gopkg.in/yaml.v2 v2.2.2
29-
gopkg.in/yaml.v3 v3.0.0-20200506231410-2ff61e1afc86
30-
sigs.k8s.io/yaml v1.1.0
25+
gopkg.in/yaml.v2 v2.3.0
26+
gopkg.in/yaml.v3 v3.0.0-20200603094226-e3079894b1e8
3127
)
28+
29+
// Cortex Overrides
30+
replace github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v36.2.0+incompatible
31+
32+
replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.0+incompatible
33+
34+
replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
35+
36+
replace github.com/satori/go.uuid => github.com/satori/go.uuid v1.2.0
37+
38+
replace k8s.io/client-go => k8s.io/client-go v0.18.3

go.sum

Lines changed: 860 additions & 216 deletions
Large diffs are not rendered by default.

pkg/chunk/migrate/writer/writer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ type Writer struct {
4040

4141
// NewWriter returns a Writer object
4242
func NewWriter(cfg Config, mapper Mapper) (*Writer, error) {
43-
overrides, err := validation.NewOverrides(validation.Limits{})
43+
overrides, err := validation.NewOverrides(validation.Limits{}, nil)
4444
if err != nil {
4545
return nil, err
4646
}
4747

48-
chunkStore, err := storage.NewStore(cfg.StorageConfig, chunk.StoreConfig{}, cfg.SchemaConfig, overrides)
48+
chunkStore, err := storage.NewStore(cfg.StorageConfig, chunk.StoreConfig{}, cfg.SchemaConfig, overrides, nil, nil)
4949
if err != nil {
5050
return nil, err
5151
}

pkg/client/rules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"io/ioutil"
66
"net/url"
77

8+
rulefmt "github.com/cortexproject/cortex/pkg/ruler/legacy_rulefmt"
89
"github.com/pkg/errors"
9-
"github.com/prometheus/prometheus/pkg/rulefmt"
1010
log "github.com/sirupsen/logrus"
1111
"gopkg.in/yaml.v2"
1212
)

pkg/commands/chunks.go

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ func (c *deleteChunkCommandOptions) run(k *kingpin.ParseContext) error {
148148
return fmt.Errorf("no schema found for provided from timestamp")
149149
}
150150

151-
ctx := context.Background()
151+
ctx, cancel := context.WithCancel(context.Background())
152+
defer cancel()
152153
fltr := filter.NewMetricFilter(c.FilterConfig)
153154

154155
var (
@@ -197,7 +198,23 @@ func (c *deleteChunkCommandOptions) run(k *kingpin.ParseContext) error {
197198
wg.Add(1)
198199

199200
go func() {
200-
schema := schemaConfig.CreateSchema()
201+
defer func() {
202+
cancel()
203+
wg.Done()
204+
}()
205+
206+
baseSchema, err := schemaConfig.CreateSchema()
207+
if err != nil {
208+
logrus.WithError(err).Errorln("unable to create schema")
209+
return
210+
}
211+
212+
schema, ok := baseSchema.(chunk.SeriesStoreSchema)
213+
if !ok {
214+
logrus.Errorln("unable to cast BaseSchema as SeriesStoreSchema")
215+
return
216+
}
217+
201218
for chk := range outChan {
202219
logrus.WithFields(logrus.Fields{
203220
"chunkID": chk.ExternalKey(),
@@ -249,7 +266,6 @@ func (c *deleteChunkCommandOptions) run(k *kingpin.ParseContext) error {
249266
}
250267

251268
}
252-
wg.Done()
253269
}()
254270

255271
table := schemaConfig.ChunkTables.TableFor(fltr.From)
@@ -314,11 +330,21 @@ func (c *deleteSeriesCommandOptions) run(k *kingpin.ParseContext) error {
314330
return fmt.Errorf("index store type %v not supported for deletes", schemaConfig.IndexType)
315331
}
316332

317-
schema := schemaConfig.CreateSchema()
333+
baseSchema, err := schemaConfig.CreateSchema()
334+
if err != nil {
335+
logrus.WithError(err).Errorln("unable to create schema")
336+
return err
337+
}
338+
339+
schema, ok := baseSchema.(chunk.SeriesStoreSchema)
340+
if !ok {
341+
logrus.Errorln("unable to cast BaseSchema as SeriesStoreSchema")
342+
return errors.New("unable to cast BaseSchema as SeriesStoreSchema")
343+
}
318344

319345
deleteMetricNameRows, err := schema.GetReadQueriesForMetric(fltr.From, fltr.To, fltr.User, fltr.Name)
320346
if err != nil {
321-
logrus.Errorln(err)
347+
return err
322348
}
323349

324350
start := time.Now()

pkg/commands/loadgen.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/prometheus/common/model"
2222
"github.com/prometheus/prometheus/prompb"
2323
"github.com/prometheus/prometheus/storage/remote"
24+
"github.com/sirupsen/logrus"
2425
"gopkg.in/alecthomas/kingpin.v2"
2526
)
2627

@@ -93,7 +94,7 @@ func (c *LoadgenCommand) run(k *kingpin.ParseContext) error {
9394
return err
9495
}
9596

96-
writeClient, err := remote.NewClient(0, &remote.ClientConfig{
97+
writeClient, err := remote.NewClient("loadgen", &remote.ClientConfig{
9798
URL: &config.URL{URL: writeURL},
9899
Timeout: model.Duration(c.writeTimeout),
99100
})
@@ -111,7 +112,12 @@ func (c *LoadgenCommand) run(k *kingpin.ParseContext) error {
111112
c.queryClient = v1.NewAPI(queryClient)
112113

113114
http.Handle("/metrics", promhttp.Handler())
114-
go http.ListenAndServe(c.metricsListenAddress, nil)
115+
go func() {
116+
err := http.ListenAndServe(c.metricsListenAddress, nil)
117+
if err != nil {
118+
logrus.WithError(err).Errorln("metrics listener failed")
119+
}
120+
}()
115121

116122
c.wg.Add(c.parallelism)
117123
c.wg.Add(c.queryParallelism)
@@ -181,10 +187,10 @@ func (c *LoadgenCommand) runBatch(from, to int) error {
181187

182188
start := time.Now()
183189
if err := c.writeClient.Store(context.Background(), compressed); err != nil {
184-
writeRequestDuration.WithLabelValues("error").Observe(time.Now().Sub(start).Seconds())
190+
writeRequestDuration.WithLabelValues("error").Observe(time.Since(start).Seconds())
185191
return err
186192
}
187-
writeRequestDuration.WithLabelValues("success").Observe(time.Now().Sub(start).Seconds())
193+
writeRequestDuration.WithLabelValues("success").Observe(time.Since(start).Seconds())
188194

189195
return nil
190196
}
@@ -207,9 +213,9 @@ func (c *LoadgenCommand) runQuery() {
207213
start := time.Now()
208214
_, _, err := c.queryClient.QueryRange(ctx, c.query, r)
209215
if err != nil {
210-
queryRequestDuration.WithLabelValues("error").Observe(time.Now().Sub(start).Seconds())
216+
queryRequestDuration.WithLabelValues("error").Observe(time.Since(start).Seconds())
211217
log.Printf("error doing query: %v", err)
212218
return
213219
}
214-
queryRequestDuration.WithLabelValues("success").Observe(time.Now().Sub(start).Seconds())
220+
queryRequestDuration.WithLabelValues("success").Observe(time.Since(start).Seconds())
215221
}

pkg/printer/printer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"strings"
77

88
"github.com/alecthomas/chroma/quick"
9+
rulefmt "github.com/cortexproject/cortex/pkg/ruler/legacy_rulefmt"
910
"github.com/mitchellh/colorstring"
10-
"github.com/prometheus/prometheus/pkg/rulefmt"
1111
"gopkg.in/yaml.v2"
1212

1313
"github.com/grafana/cortextool/pkg/rules"

pkg/rules/compare.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"reflect"
77
"strings"
88

9+
rulefmt "github.com/cortexproject/cortex/pkg/ruler/legacy_rulefmt"
910
"github.com/mitchellh/colorstring"
10-
"github.com/prometheus/prometheus/pkg/rulefmt"
11-
"sigs.k8s.io/yaml"
11+
yaml "gopkg.in/yaml.v2"
1212
)
1313

1414
var (

pkg/rules/parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/prometheus/prometheus/pkg/rulefmt"
7+
rulefmt "github.com/cortexproject/cortex/pkg/ruler/legacy_rulefmt"
88
)
99

1010
func TestParseFiles(t *testing.T) {

pkg/rules/rules.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/prometheus/prometheus/pkg/rulefmt"
8-
"github.com/prometheus/prometheus/promql"
7+
rulefmt "github.com/cortexproject/cortex/pkg/ruler/legacy_rulefmt"
8+
"github.com/prometheus/prometheus/promql/parser"
99
log "github.com/sirupsen/logrus"
1010
)
1111

@@ -29,7 +29,7 @@ func (r RuleNamespace) LintPromQLExpressions() (int, int, error) {
2929
for i, group := range r.Groups {
3030
for j, rule := range group.Rules {
3131
log.WithFields(log.Fields{"rule": getRuleName(rule)}).Debugf("linting PromQL")
32-
exp, err := promql.ParseExpr(rule.Expr)
32+
exp, err := parser.ParseExpr(rule.Expr)
3333
if err != nil {
3434
return count, mod, err
3535
}
@@ -61,7 +61,7 @@ func (r RuleNamespace) AggregateBy(label string) (int, int, error) {
6161
for i, group := range r.Groups {
6262
for j, rule := range group.Rules {
6363
log.WithFields(log.Fields{"rule": getRuleName(rule)}).Debugf("evaluating...")
64-
exp, err := promql.ParseExpr(rule.Expr)
64+
exp, err := parser.ParseExpr(rule.Expr)
6565
if err != nil {
6666
return count, mod, err
6767
}
@@ -70,7 +70,7 @@ func (r RuleNamespace) AggregateBy(label string) (int, int, error) {
7070
// Given inspect will help us traverse every node in the AST, Let's create the
7171
// function that will modify the labels.
7272
f := exprNodeInspectorFunc(rule, label)
73-
promql.Inspect(exp, f)
73+
parser.Inspect(exp, f)
7474

7575
// Only modify the ones that actually changed.
7676
if rule.Expr != exp.String() {
@@ -90,9 +90,9 @@ func (r RuleNamespace) AggregateBy(label string) (int, int, error) {
9090

9191
// exprNodeInspectorFunc returns a PromQL inspector.
9292
// It modifies most PromQL aggregations to include a given label.
93-
func exprNodeInspectorFunc(rule rulefmt.Rule, label string) func(node promql.Node, path []promql.Node) error {
94-
return func(node promql.Node, path []promql.Node) error {
95-
aggregation, ok := node.(*promql.AggregateExpr)
93+
func exprNodeInspectorFunc(rule rulefmt.Rule, label string) func(node parser.Node, path []parser.Node) error {
94+
return func(node parser.Node, path []parser.Node) error {
95+
aggregation, ok := node.(*parser.AggregateExpr)
9696
if !ok {
9797
return nil
9898
}

0 commit comments

Comments
 (0)