Skip to content

Upgraded Thanos dependency #1935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 16 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ module github.com/cortexproject/cortex
go 1.12

require (
cloud.google.com/go v0.44.1
cloud.google.com/go/bigtable v1.1.0
cloud.google.com/go/storage v1.3.0
github.com/Azure/azure-storage-blob-go v0.8.0
github.com/Azure/go-autorest/autorest v0.9.2 // indirect
github.com/Azure/go-autorest/autorest/adal v0.8.0 // indirect
github.com/Azure/go-autorest/autorest/to v0.3.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect
github.com/Masterminds/squirrel v0.0.0-20161115235646-20f192218cf5
github.com/NYTimes/gziphandler v1.1.1
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878
github.com/aws/aws-sdk-go v1.25.22
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d
github.com/armon/go-metrics v0.3.0
github.com/aws/aws-sdk-go v1.25.35
github.com/blang/semver v3.5.0+incompatible
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668
github.com/cenkalti/backoff v1.0.0 // indirect
Expand All @@ -27,7 +24,7 @@ require (
github.com/go-kit/kit v0.9.0
github.com/gocql/gocql v0.0.0-20190301043612-f6df8288f9b4
github.com/gogo/googleapis v1.1.0 // indirect
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48
github.com/gogo/protobuf v1.3.1
github.com/gogo/status v1.0.3
github.com/golang-migrate/migrate/v4 v4.7.0
github.com/golang/protobuf v1.3.2
Expand All @@ -36,11 +33,11 @@ require (
github.com/gorilla/mux v1.7.1
github.com/gorilla/websocket v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0
github.com/hashicorp/consul/api v1.1.0
github.com/hashicorp/consul/api v1.3.0
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/go-sockaddr v1.0.2
github.com/hashicorp/memberlist v0.1.4
github.com/json-iterator/go v1.1.7
github.com/hashicorp/memberlist v0.1.5
github.com/json-iterator/go v1.1.8
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 // indirect
github.com/lann/builder v0.0.0-20150808151131-f22ce00fd939 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
Expand All @@ -52,28 +49,28 @@ require (
github.com/philhofer/fwd v0.0.0-20160129035939-98c11a7a6ec8 // indirect
github.com/pkg/errors v0.8.1
github.com/prometheus/alertmanager v0.19.0
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/client_golang v1.2.1
github.com/prometheus/common v0.7.0
github.com/prometheus/prometheus v1.8.2-0.20190918104050-8744afdd1ea0
github.com/prometheus/prometheus v1.8.2-0.20191126064551-80ba03c67da1
github.com/rafaeljusto/redigomock v0.0.0-20190202135759-257e089e14a1
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e
github.com/sercand/kuberesolver v2.1.0+incompatible // indirect
github.com/spf13/afero v1.2.2
github.com/stretchr/testify v1.4.0
github.com/thanos-io/thanos v0.8.1
github.com/thanos-io/thanos v0.8.1-0.20200102143048-a37ac093a67a
github.com/tinylib/msgp v0.0.0-20161221055906-38a6f61a768d // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/uber/jaeger-client-go v2.20.0+incompatible
github.com/uber/jaeger-client-go v2.20.1+incompatible
github.com/weaveworks/billing-client v0.0.0-20171006123215-be0d55e547b1
github.com/weaveworks/common v0.0.0-20190822150010-afb9996716e4
github.com/weaveworks/promrus v1.2.0 // indirect
go.etcd.io/bbolt v1.3.3
go.etcd.io/etcd v0.0.0-20190709142735-eb7dd97135a5
golang.org/x/net v0.0.0-20190923162816-aa69164e4478
golang.org/x/net v0.0.0-20191112182307-2180aed22343
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
google.golang.org/api v0.11.0
google.golang.org/api v0.14.0
google.golang.org/grpc v1.25.1
gopkg.in/yaml.v2 v2.2.2
gopkg.in/yaml.v2 v2.2.5
)

replace github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v36.2.0+incompatible
Expand Down
244 changes: 201 additions & 43 deletions go.sum

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions pkg/cortex/modules.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cortex

import (
"errors"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -226,6 +227,8 @@ func (t *Cortex) initQuerier(cfg *Config) (err error) {
querier.DummyRulesRetriever{},
0, 0, 0, // Remote read samples and concurrency limit.
regexp.MustCompile(".*"),
func() (v1.RuntimeInfo, error) { return v1.RuntimeInfo{}, errors.New("not implemented") },
&v1.PrometheusVersion{},
)
promRouter := route.New().WithPrefix("/api/prom/api/v1")
api.Register(promRouter)
Expand Down
5 changes: 5 additions & 0 deletions pkg/ingester/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ func (b *Bucket) Exists(ctx context.Context, name string) (bool, error) {
func (b *Bucket) IsObjNotFoundErr(err error) bool {
return b.Bucket.IsObjNotFoundErr(err)
}

// ObjectSize returns the size of the specified object.
func (b *Bucket) ObjectSize(ctx context.Context, name string) (uint64, error) {
return b.Bucket.ObjectSize(ctx, b.fullName(name))
}
16 changes: 16 additions & 0 deletions pkg/ingester/client/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ func FromLabelAdaptersToLabels(ls []LabelAdapter) labels.Labels {
return *(*labels.Labels)(unsafe.Pointer(&ls))
}

// FromLabelAdaptersToLabelsWithCopy converts []LabelAdapter to labels.Labels.
// Do NOT use unsafe to convert between data types because this function may
// get in input labels whose data structure is reused.
func FromLabelAdaptersToLabelsWithCopy(input []LabelAdapter) labels.Labels {
result := make(labels.Labels, len(input))

for i, l := range input {
result[i] = labels.Label{
Name: l.Name,
Value: l.Value,
}
}

return result
}

// FromLabelsToLabelAdapters casts labels.Labels to []LabelAdapter.
// It uses unsafe, but as LabelAdapter == labels.Label this should be safe.
// This allows us to use labels.Labels directly in protos.
Expand Down
26 changes: 8 additions & 18 deletions pkg/ingester/ingester_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/cortexproject/cortex/pkg/util/validation"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/tsdb"
lbls "github.com/prometheus/prometheus/tsdb/labels"
"github.com/thanos-io/thanos/pkg/block/metadata"
"github.com/thanos-io/thanos/pkg/objstore"
"github.com/thanos-io/thanos/pkg/runutil"
Expand Down Expand Up @@ -119,7 +119,7 @@ func (i *Ingester) v2Push(ctx old_ctx.Context, req *client.WriteRequest) (*clien
app := db.Appender()
for _, ts := range req.Timeseries {
// Convert labels to the type expected by TSDB
lset := cortex_tsdb.FromLabelAdaptersToLabels(ts.Labels)
lset := client.FromLabelAdaptersToLabelsWithCopy(ts.Labels)

for _, s := range ts.Samples {
_, err := app.Add(lset, s.TimestampMs, s.Value)
Expand Down Expand Up @@ -189,12 +189,7 @@ func (i *Ingester) v2Query(ctx old_ctx.Context, req *client.QueryRequest) (*clie
}
defer q.Close()

convertedMatchers, err := cortex_tsdb.FromLegacyLabelMatchersToMatchers(matchers)
if err != nil {
return nil, err
}

ss, err := q.Select(convertedMatchers...)
ss, err := q.Select(matchers...)
if err != nil {
return nil, err
}
Expand All @@ -204,7 +199,7 @@ func (i *Ingester) v2Query(ctx old_ctx.Context, req *client.QueryRequest) (*clie
series := ss.At()

ts := client.TimeSeries{
Labels: cortex_tsdb.FromLabelsToLabelAdapters(series.Labels()),
Labels: client.FromLabelsToLabelAdapters(series.Labels()),
}

it := series.Iterator()
Expand Down Expand Up @@ -308,12 +303,7 @@ func (i *Ingester) v2MetricsForLabelMatchers(ctx old_ctx.Context, req *client.Me
}

for _, matchers := range matchersSet {
convertedMatchers, err := cortex_tsdb.FromLegacyLabelMatchersToMatchers(matchers)
if err != nil {
return nil, err
}

seriesSet, err := q.Select(convertedMatchers...)
seriesSet, err := q.Select(matchers...)
if err != nil {
return nil, err
}
Expand All @@ -333,7 +323,7 @@ func (i *Ingester) v2MetricsForLabelMatchers(ctx old_ctx.Context, req *client.Me
}

result.Metric = append(result.Metric, &client.Metric{
Labels: cortex_tsdb.FromLabelsToLabelAdapters(ls),
Labels: client.FromLabelsToLabelAdapters(ls),
})

added[key] = struct{}{}
Expand Down Expand Up @@ -398,15 +388,15 @@ func (i *Ingester) getOrCreateTSDB(userID string, force bool) (*tsdb.DB, error)
// Thanos shipper requires at least 1 external label to be set. For this reason,
// we set the tenant ID as external label and we'll filter it out when reading
// the series from the storage.
l := lbls.Labels{
l := labels.Labels{
{
Name: cortex_tsdb.TenantIDExternalLabel,
Value: userID,
},
}

// Create a new shipper for this database
s := shipper.New(util.Logger, nil, udir, &Bucket{userID, i.TSDBState.bucket}, func() lbls.Labels { return l }, metadata.ReceiveSource)
s := shipper.New(util.Logger, nil, udir, &Bucket{userID, i.TSDBState.bucket}, func() labels.Labels { return l }, metadata.ReceiveSource)
i.done.Add(1)
go func() {
defer i.done.Done()
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/block_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (u *UserStore) syncUserStores(ctx context.Context, f func(context.Context,

indexCacheSizeBytes := u.cfg.BucketStore.IndexCacheSizeBytes
maxItemSizeBytes := indexCacheSizeBytes / 2
indexCache, err := storecache.NewIndexCache(u.logger, nil, storecache.Opts{
indexCache, err := storecache.NewInMemoryIndexCache(u.logger, nil, storecache.Opts{
MaxSizeBytes: indexCacheSizeBytes,
MaxItemSizeBytes: maxItemSizeBytes,
})
Expand Down
9 changes: 7 additions & 2 deletions pkg/storage/tsdb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ import (
"github.com/cortexproject/cortex/pkg/storage/tsdb/backend/s3"
)

// Constants for the config values
const (
BackendS3 = "s3"
// BackendS3 is the value for the S3 storage backend
BackendS3 = "s3"

// BackendGCS is the value for the GCS storage backend
BackendGCS = "gcs"

// TenantIDExternalLabel is the external label set when shipping blocks to the storage
TenantIDExternalLabel = "__org_id__"
)

// Validation errors
Expand Down
70 changes: 0 additions & 70 deletions pkg/storage/tsdb/labels.go

This file was deleted.

Loading