diff --git a/.golangci.yml b/.golangci.yml index 09aa3515945..77d8f8cab64 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,6 +4,7 @@ output: linters: enable: - goimports + - revive - gofmt - misspell - depguard @@ -18,12 +19,18 @@ linters-settings: exclude: ./.errcheck-exclude goimports: local-prefixes: "github.com/cortexproject/cortex" + revive: + severity: error # We only want critical issues. depguard: - list-type: blacklist - include-go-root: true - packages-with-error-message: - - github.com/go-kit/kit/log: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log" + rules: + main: + list-mode: lax + files: + - $all + deny: + - pkg: "github.com/go-kit/kit/log" + desc: Use github.com/go-kit/log instead of github.com/go-kit/kit/log" run: timeout: 5m diff --git a/integration/backward_compatibility_test.go b/integration/backward_compatibility_test.go index 50194c8170b..2ae0b07ad87 100644 --- a/integration/backward_compatibility_test.go +++ b/integration/backward_compatibility_test.go @@ -33,14 +33,6 @@ var ( } ) -func preCortex110Flags(flags map[string]string) map[string]string { - return e2e.MergeFlagsWithoutRemovingEmpty(flags, map[string]string{ - // Store-gateway "wait ring stability" has been introduced in 1.10.0 - "-store-gateway.sharding-ring.wait-stability-min-duration": "", - "-store-gateway.sharding-ring.wait-stability-max-duration": "", - }) -} - func TestBackwardCompatibilityWithBlocksStorage(t *testing.T) { for previousImage, flagsFn := range previousVersionImages { t.Run(fmt.Sprintf("Backward compatibility upgrading from %s", previousImage), func(t *testing.T) { diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index 938584eba31..30e4d799d5e 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -555,9 +555,7 @@ func (d *Distributor) validateSeries(ts cortexpb.PreallocTimeseries, userID stri histograms = make([]cortexpb.Histogram, 0, len(ts.Histograms)) // TODO(yeya24): we need to have validations for native histograms // at some point. Skip validations for now. - for _, h := range ts.Histograms { - histograms = append(histograms, h) - } + histograms = append(histograms, ts.Histograms...) } return cortexpb.PreallocTimeseries{ diff --git a/pkg/querier/testutils.go b/pkg/querier/testutils.go index 650d93f7271..a60e6761f5e 100644 --- a/pkg/querier/testutils.go +++ b/pkg/querier/testutils.go @@ -2,16 +2,17 @@ package querier import ( "context" - "github.com/cortexproject/cortex/pkg/cortexpb" - "github.com/cortexproject/cortex/pkg/util/limiter" + "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/scrape" "github.com/stretchr/testify/mock" + "github.com/cortexproject/cortex/pkg/cortexpb" "github.com/cortexproject/cortex/pkg/ingester/client" "github.com/cortexproject/cortex/pkg/prom1/storage/metric" "github.com/cortexproject/cortex/pkg/util/flagext" + "github.com/cortexproject/cortex/pkg/util/limiter" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/pkg/storage/tsdb/bucketindex/block_ids_fetcher_test.go b/pkg/storage/tsdb/bucketindex/block_ids_fetcher_test.go index 5a43ec8660f..bd25f15dcf2 100644 --- a/pkg/storage/tsdb/bucketindex/block_ids_fetcher_test.go +++ b/pkg/storage/tsdb/bucketindex/block_ids_fetcher_test.go @@ -53,7 +53,8 @@ func TestBlockIDsFetcher_Fetch(t *testing.T) { blockIds = append(blockIds, id) } }() - blockIdsFetcher.GetActiveAndPartialBlockIDs(ctx, ch) + _, err := blockIdsFetcher.GetActiveAndPartialBlockIDs(ctx, ch) + require.NoError(t, err) close(ch) wg.Wait() require.Equal(t, []ulid.ULID{block3.ID}, blockIds) @@ -104,7 +105,8 @@ func TestBlockIDsFetcherFetcher_Fetch_NoBucketIndex(t *testing.T) { blockIds = append(blockIds, id) } }() - blockIdsFetcher.GetActiveAndPartialBlockIDs(ctx, ch) + _, err := blockIdsFetcher.GetActiveAndPartialBlockIDs(ctx, ch) + require.NoError(t, err) close(ch) wg.Wait() require.Equal(t, []ulid.ULID{block1.ID, block2.ID, block3.ID}, blockIds) diff --git a/pkg/storage/tsdb/inmemory_index_cache_test.go b/pkg/storage/tsdb/inmemory_index_cache_test.go index aba9099a54f..530d26575ce 100644 --- a/pkg/storage/tsdb/inmemory_index_cache_test.go +++ b/pkg/storage/tsdb/inmemory_index_cache_test.go @@ -4,6 +4,12 @@ import ( "bytes" "context" "fmt" + "math/rand" + "strconv" + "strings" + "testing" + "time" + "github.com/efficientgo/core/testutil" "github.com/go-kit/log" "github.com/oklog/ulid" @@ -14,11 +20,6 @@ import ( "github.com/stretchr/testify/require" storecache "github.com/thanos-io/thanos/pkg/store/cache" "github.com/thanos-io/thanos/pkg/tenancy" - "math/rand" - "strconv" - "strings" - "testing" - "time" ) func TestInMemoryIndexCache_UpdateItem(t *testing.T) { diff --git a/pkg/storage/tsdb/users_scanner.go b/pkg/storage/tsdb/users_scanner.go index 2c0d463d259..0fe24395bf5 100644 --- a/pkg/storage/tsdb/users_scanner.go +++ b/pkg/storage/tsdb/users_scanner.go @@ -4,10 +4,11 @@ import ( "context" "strings" - "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/thanos-io/objstore" + + "github.com/cortexproject/cortex/pkg/util" ) // AllUsers returns true to each call and should be used whenever the UsersScanner should not filter out diff --git a/pkg/tracing/migration/bridge_wrapper_test.go b/pkg/tracing/migration/bridge_wrapper_test.go index 24afb1409fa..ea3375958cb 100644 --- a/pkg/tracing/migration/bridge_wrapper_test.go +++ b/pkg/tracing/migration/bridge_wrapper_test.go @@ -9,6 +9,7 @@ import ( "github.com/weaveworks/common/httpgrpc" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" + "go.opentelemetry.io/otel/trace/noop" "github.com/cortexproject/cortex/pkg/util/httpgrpcutil" ) @@ -18,7 +19,7 @@ var ( spanID trace.SpanID = [8]byte{byte(11)} traceIDKey = "Traceid" spanIDKey = "Spanid" - noopTracer = trace.NewNoopTracerProvider().Tracer("") + noopTracer = noop.NewTracerProvider().Tracer("") noopSpan = func() trace.Span { _, s := noopTracer.Start(context.Background(), "") return s