Skip to content

Commit

Permalink
Upgrade Cortex (#3466)
Browse files Browse the repository at this point in the history
* Upgrade Cortex

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Updated vendor/modules.txt

Signed-off-by: Marco Pracucci <marco@pracucci.com>
  • Loading branch information
pracucci authored Mar 12, 2021
1 parent 64decdb commit 9404130
Show file tree
Hide file tree
Showing 183 changed files with 8,192 additions and 5,618 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.1
github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/cortexproject/cortex v1.7.1-0.20210308081334-2dae12a14c48
github.com/cortexproject/cortex v1.7.1-0.20210310133228-161f103ed5ba
github.com/davecgh/go-spew v1.1.1
github.com/docker/docker v20.10.3+incompatible
github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 // indirect
Expand Down Expand Up @@ -74,6 +74,9 @@ require (
k8s.io/klog v1.0.0
)

// Upgrade to run with gRPC 1.3.0 and above.
replace github.com/sercand/kuberesolver => github.com/sercand/kuberesolver v2.4.0+incompatible

replace github.com/hpcloud/tail => github.com/grafana/tail v0.0.0-20201004203643-7aa4e4a91f03

replace github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v36.2.0+incompatible
Expand All @@ -91,9 +94,6 @@ replace github.com/satori/go.uuid => github.com/satori/go.uuid v1.2.0
// Use fork of gocql that has gokit logs and Prometheus metrics.
replace github.com/gocql/gocql => github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85

// Same as Cortex, we can't upgrade to grpc 1.30.0 until go.etcd.io/etcd will support it.
replace google.golang.org/grpc => google.golang.org/grpc v1.29.1

// Same as Cortex
// Using a 3rd-party branch for custom dialer - see https://github.com/bradfitz/gomemcache/pull/86
replace github.com/bradfitz/gomemcache => github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab
Expand Down
142 changes: 48 additions & 94 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/ingester/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strconv"
"time"

"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/cortexpb"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/dustin/go-humanize"
"github.com/go-kit/kit/log"
Expand Down Expand Up @@ -267,7 +267,7 @@ func (s *streamIterator) Next() bool {

s.current.UserID = currentInstance.id
s.current.Fingerprint = uint64(stream.fp)
s.current.Labels = client.FromLabelsToLabelAdapters(stream.labels)
s.current.Labels = cortexpb.FromLabelsToLabelAdapters(stream.labels)

s.current.To = stream.lastLine.ts
s.current.LastLine = stream.lastLine.content
Expand Down
6 changes: 3 additions & 3 deletions pkg/ingester/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/cortexproject/cortex/pkg/chunk"
cortex_client "github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/cortexproject/cortex/pkg/util/services"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -476,7 +476,7 @@ func Test_SeriesIterator(t *testing.T) {
it, err := memchunk.Iterator(context.Background(), time.Unix(0, 0), time.Unix(0, 100), logproto.FORWARD, log.NewNoopPipeline().ForStream(nil))
require.NoError(t, err)
stream := logproto.Stream{
Labels: cortex_client.FromLabelAdaptersToLabels(iter.Stream().Labels).String(),
Labels: cortexpb.FromLabelAdaptersToLabels(iter.Stream().Labels).String(),
}
for it.Next() {
stream.Entries = append(stream.Entries, it.Entry())
Expand Down Expand Up @@ -552,7 +552,7 @@ func Benchmark_CheckpointWrite(b *testing.B) {
require.NoError(b, writer.Write(&Series{
UserID: "foo",
Fingerprint: lbs.Hash(),
Labels: cortex_client.FromLabelsToLabelAdapters(lbs),
Labels: cortexpb.FromLabelsToLabelAdapters(lbs),
Chunks: chunks,
}))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ingester/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/tsdb/record"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -242,7 +242,7 @@ func Test_EncodingCheckpoint(t *testing.T) {
s := &Series{
UserID: "fake",
Fingerprint: 123,
Labels: client.FromLabelsToLabelAdapters(ls),
Labels: cortexpb.FromLabelsToLabelAdapters(ls),
To: time.Unix(10, 0),
LastLine: "lastLine",
Chunks: []Chunk{
Expand Down
6 changes: 3 additions & 3 deletions pkg/ingester/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sync"
"syscall"

"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/weaveworks/common/httpgrpc"
"go.uber.org/atomic"

"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/ingester/index"
cutil "github.com/cortexproject/cortex/pkg/util"
util_log "github.com/cortexproject/cortex/pkg/util/log"
Expand Down Expand Up @@ -126,7 +126,7 @@ func (i *instance) consumeChunk(ctx context.Context, ls labels.Labels, chunk *lo
stream, ok := i.streamsByFP[fp]
if !ok {

sortedLabels := i.index.Add(client.FromLabelsToLabelAdapters(ls), fp)
sortedLabels := i.index.Add(cortexpb.FromLabelsToLabelAdapters(ls), fp)
stream = newStream(i.cfg, fp, sortedLabels, i.metrics)
i.streamsByFP[fp] = stream
i.streams[stream.labelsString] = stream
Expand Down Expand Up @@ -237,7 +237,7 @@ func (i *instance) getOrCreateStream(pushReqStream logproto.Stream, lock bool, r
}
fp := i.getHashForLabels(labels)

sortedLabels := i.index.Add(client.FromLabelsToLabelAdapters(labels), fp)
sortedLabels := i.index.Add(cortexpb.FromLabelsToLabelAdapters(labels), fp)
stream = newStream(i.cfg, fp, sortedLabels, i.metrics)
i.streams[pushReqStream.Labels] = stream
i.streamsByFP[fp] = stream
Expand Down
4 changes: 2 additions & 2 deletions pkg/ingester/recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"runtime"
"sync"

"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/cortexpb"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
Expand Down Expand Up @@ -115,7 +115,7 @@ func (r *ingesterRecoverer) Series(series *Series) error {

// TODO(owen-d): create another fn to avoid unnecessary label type conversions.
stream, err := inst.getOrCreateStream(logproto.Stream{
Labels: client.FromLabelAdaptersToLabels(series.Labels).String(),
Labels: cortexpb.FromLabelAdaptersToLabels(series.Labels).String(),
}, true, nil)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/querier_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func mockReadRingWithOneActiveIngester() *readRingMock {
})
}

func mockInstanceDesc(addr string, state ring.IngesterState) ring.InstanceDesc {
func mockInstanceDesc(addr string, state ring.InstanceState) ring.InstanceDesc {
return ring.InstanceDesc{
Addr: addr,
Timestamp: time.Now().UnixNano(),
Expand Down
8 changes: 4 additions & 4 deletions pkg/querier/queryrange/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
strings "strings"
"time"

"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
json "github.com/json-iterator/go"
"github.com/opentracing/opentracing-go"
Expand Down Expand Up @@ -620,15 +620,15 @@ func toProto(m loghttp.Matrix) []queryrange.SampleStream {
}
res := make([]queryrange.SampleStream, 0, len(m))
for _, stream := range m {
samples := make([]client.Sample, 0, len(stream.Values))
samples := make([]cortexpb.Sample, 0, len(stream.Values))
for _, s := range stream.Values {
samples = append(samples, client.Sample{
samples = append(samples, cortexpb.Sample{
Value: float64(s.Value),
TimestampMs: int64(s.Timestamp),
})
}
res = append(res, queryrange.SampleStream{
Labels: client.FromMetricsToLabelAdapters(stream.Metric),
Labels: cortexpb.FromMetricsToLabelAdapters(stream.Metric),
Samples: samples,
})
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/querier/queryrange/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -905,12 +905,12 @@ var (
}`
sampleStreams = []queryrange.SampleStream{
{
Labels: []client.LabelAdapter{{Name: "filename", Value: "/var/hostlog/apport.log"}, {Name: "job", Value: "varlogs"}},
Samples: []client.Sample{{Value: 0.013333333333333334, TimestampMs: 1568404331324}},
Labels: []cortexpb.LabelAdapter{{Name: "filename", Value: "/var/hostlog/apport.log"}, {Name: "job", Value: "varlogs"}},
Samples: []cortexpb.Sample{{Value: 0.013333333333333334, TimestampMs: 1568404331324}},
},
{
Labels: []client.LabelAdapter{{Name: "filename", Value: "/var/hostlog/syslog"}, {Name: "job", Value: "varlogs"}},
Samples: []client.Sample{{Value: 3.45, TimestampMs: 1568404331324}, {Value: 4.45, TimestampMs: 1568404331339}},
Labels: []cortexpb.LabelAdapter{{Name: "filename", Value: "/var/hostlog/syslog"}, {Name: "job", Value: "varlogs"}},
Samples: []cortexpb.Sample{{Value: 3.45, TimestampMs: 1568404331324}, {Value: 4.45, TimestampMs: 1568404331339}},
},
}
streamsString = `{
Expand Down
10 changes: 5 additions & 5 deletions pkg/querier/queryrange/downstreamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
Expand All @@ -21,8 +21,8 @@ import (
func testSampleStreams() []queryrange.SampleStream {
return []queryrange.SampleStream{
{
Labels: []client.LabelAdapter{{Name: "foo", Value: "bar"}},
Samples: []client.Sample{
Labels: []cortexpb.LabelAdapter{{Name: "foo", Value: "bar"}},
Samples: []cortexpb.Sample{
{
Value: 0,
TimestampMs: 0,
Expand All @@ -38,8 +38,8 @@ func testSampleStreams() []queryrange.SampleStream {
},
},
{
Labels: []client.LabelAdapter{{Name: "bazz", Value: "buzz"}},
Samples: []client.Sample{
Labels: []cortexpb.LabelAdapter{{Name: "bazz", Value: "buzz"}},
Samples: []cortexpb.Sample{
{
Value: 4,
TimestampMs: 4,
Expand Down
4 changes: 2 additions & 2 deletions pkg/querier/queryrange/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/opentracing/opentracing-go"
"github.com/weaveworks/common/httpgrpc"
Expand Down Expand Up @@ -126,7 +126,7 @@ func (sl *seriesLimiter) Do(ctx context.Context, req queryrange.Request) (queryr
sl.rw.Lock()
var hash uint64
for _, s := range promResponse.Response.Data.Result {
lbs := client.FromLabelAdaptersToLabels(s.Labels)
lbs := cortexpb.FromLabelAdaptersToLabels(s.Labels)
hash, sl.buf = lbs.HashWithoutLabels(sl.buf, []string(nil)...)
sl.hashes[hash] = struct{}{}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9404130

Please sign in to comment.