Skip to content

Commit

Permalink
Remove call to set default resolver (#11580)
Browse files Browse the repository at this point in the history
**What this PR does / why we need it**:

**Which issue(s) this PR fixes**:
Fixes #<issue number>

**Special notes for your reviewer**:

**Checklist**
- [ ] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [ ] Documentation added
- [ ] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/setup/upgrade/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](d10549e)
- [ ] If the change is deprecating or removing a configuration option,
update the `deprecated-config.yaml` and `deleted-config.yaml` files
respectively in the `tools/deprecated-config-checker` directory.
[Example
PR](0d4416a)
  • Loading branch information
paul1r authored Jan 5, 2024
1 parent 599eed7 commit 6c4699d
Show file tree
Hide file tree
Showing 80 changed files with 4,983 additions and 975 deletions.
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.5.0
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2
github.com/grafana/dskit v0.0.0-20231120170505-765e343eda4f
github.com/grafana/dskit v0.0.0-20240104111617-ea101a3b86eb
github.com/grafana/go-gelf/v2 v2.0.1
github.com/grafana/gomemcache v0.0.0-20231204155601-7de47a8c3cb0
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd
Expand All @@ -66,7 +66,7 @@ require (
github.com/jmespath/go-jmespath v0.4.0
github.com/joncrlsn/dque v0.0.0-20211108142734-c2ef48c5192a
github.com/json-iterator/go v1.1.12
github.com/klauspost/compress v1.16.7
github.com/klauspost/compress v1.17.3
github.com/klauspost/pgzip v1.2.5
github.com/mattn/go-ieproxy v0.0.1
github.com/minio/minio-go/v7 v7.0.61
Expand Down Expand Up @@ -235,6 +235,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/gophercloud/gophercloud v1.5.0 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,8 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I=
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2/go.mod h1:w/aiO1POVIeXUQyl0VQSZjl5OAGDTL5aX+4v0RA1tcw=
github.com/grafana/dskit v0.0.0-20231120170505-765e343eda4f h1:gyojr97YeWZ70pKNakWv5/tKwBHuLy3icnIeCo9gQr4=
github.com/grafana/dskit v0.0.0-20231120170505-765e343eda4f/go.mod h1:8dsy5tQOkeNQyjXpm5mQsbCu3H5uzeBD35MzRQFznKU=
github.com/grafana/dskit v0.0.0-20240104111617-ea101a3b86eb h1:AWE6+kvtE18HP+lRWNUCyvymyrFSXs6TcS2vXIXGIuw=
github.com/grafana/dskit v0.0.0-20240104111617-ea101a3b86eb/go.mod h1:kkWM4WUV230bNG3urVRWPBnSJHs64y/0RmWjftnnn0c=
github.com/grafana/go-gelf/v2 v2.0.1 h1:BOChP0h/jLeD+7F9mL7tq10xVkDG15he3T1zHuQaWak=
github.com/grafana/go-gelf/v2 v2.0.1/go.mod h1:lexHie0xzYGwCgiRGcvZ723bSNyNI8ZRD4s0CLobh90=
github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/IENCw+oLVdZB4G21VPhkHBgwSHY=
Expand All @@ -1005,6 +1005,8 @@ github.com/grafana/gomemcache v0.0.0-20231204155601-7de47a8c3cb0 h1:aLBiDMjTtXx2
github.com/grafana/gomemcache v0.0.0-20231204155601-7de47a8c3cb0/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU=
github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe h1:yIXAAbLswn7VNWBIvM71O2QsgfgW9fRXZNR0DXe6pDU=
github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 h1:nEdZ8louGAplSvIJi1HVp7kWvFvdiiYg3COLlTwJiFo=
github.com/grafana/pyroscope-go/godeltaprof v0.1.6/go.mod h1:Tk376Nbldo4Cha9RgiU7ik8WKFkNpfds98aUzS8omLE=
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd h1:PpuIBO5P3e9hpqBD0O/HjhShYuM6XE0i/lbE6J94kww=
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd/go.mod h1:M5qHK+eWfAv8VR/265dIuEpL3fNfeC21tXXp9itM24A=
github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0 h1:bjh0PVYSVVFxzINqPFYJmAmJNrWPgnVjuSdYJGHmtFU=
Expand Down Expand Up @@ -1239,8 +1241,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.17.3 h1:qkRjuerhUU1EmXLYGkSH6EZL+vPSxIrYjLNAK4slzwA=
github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
Expand Down
5 changes: 5 additions & 0 deletions pkg/bloomgateway/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,8 @@ func (*mockRing) ShuffleShardWithLookback(_ string, _ int, _ time.Duration, _ ti
func (*mockRing) CleanupShuffleShardCache(_ string) {
panic("unimplemented")
}

func (r *mockRing) GetTokenRangesForInstance(_ string) (ring.TokenRanges, error) {
tr := ring.TokenRanges{0, math.MaxUint32}
return tr, nil
}
4 changes: 2 additions & 2 deletions pkg/compactor/deletion/request_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func TestCancelDeleteRequestHandler(t *testing.T) {
store.getErr = errors.New("something bad")
h := NewDeleteRequestHandler(store, 0, nil)

req := buildRequest("org id", ``, "", "")
req := buildRequest("orgid", ``, "", "")
params := req.URL.Query()
params.Set("request_id", "test-request")
req.URL.RawQuery = params.Encode()
Expand Down Expand Up @@ -411,7 +411,7 @@ func TestGetAllDeleteRequestsHandler(t *testing.T) {
store.getAllErr = errors.New("something bad")
h := NewDeleteRequestHandler(store, 0, nil)

req := buildRequest("org id", ``, "", "")
req := buildRequest("orgid", ``, "", "")
params := req.URL.Query()
params.Set("request_id", "test-request")
req.URL.RawQuery = params.Encode()
Expand Down
8 changes: 0 additions & 8 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/grafana/dskit/runtimeconfig"
"github.com/grafana/dskit/server"
"github.com/grafana/dskit/services"
"github.com/grafana/dskit/tenant"
"github.com/grafana/dskit/user"
gerrors "github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -332,12 +331,6 @@ func (t *Loki) initDistributor() (services.Service, error) {
logproto.RegisterPusherServer(t.Server.GRPC, t.distributor)
}

// If the querier module is not part of this process we need to check if multi-tenant queries are enabled.
// If the querier module is part of this process the querier module will configure everything.
if !t.Cfg.isModuleEnabled(Querier) && t.Cfg.Querier.MultiTenantQueriesEnabled {
tenant.WithDefaultResolver(tenant.NewMultiResolver())
}

httpPushHandlerMiddleware := middleware.Merge(
serverutil.RecoveryHTTPMiddleware,
t.HTTPAuthMiddleware,
Expand Down Expand Up @@ -383,7 +376,6 @@ func (t *Loki) initQuerier() (services.Service, error) {

if t.Cfg.Querier.MultiTenantQueriesEnabled {
t.Querier = querier.NewMultiTenantQuerier(q, util_log.Logger)
tenant.WithDefaultResolver(tenant.NewMultiResolver())
} else {
t.Querier = q
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/querier/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ import (
"github.com/grafana/loki/pkg/validation"

"github.com/go-kit/log"
"github.com/grafana/dskit/tenant"
"github.com/grafana/dskit/user"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
)

func TestTailHandler(t *testing.T) {
tenant.WithDefaultResolver(tenant.NewMultiResolver())

defaultLimits := defaultLimitsTestConfig()
limits, err := validation.NewOverrides(defaultLimits, nil)
require.NoError(t, err)
Expand Down Expand Up @@ -78,7 +75,6 @@ func (s *slowConnectionSimulator) ServeHTTP(_ http.ResponseWriter, r *http.Reque
}

func TestQueryWrapperMiddleware(t *testing.T) {
tenant.WithDefaultResolver(tenant.NewMultiResolver())
shortestTimeout := time.Millisecond * 5

t.Run("request timeout is the shortest one", func(t *testing.T) {
Expand Down
12 changes: 0 additions & 12 deletions pkg/querier/multi_tenant_querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/grafana/dskit/tenant"

"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
Expand All @@ -25,8 +23,6 @@ import (
)

func TestMultiTenantQuerier_SelectLogs(t *testing.T) {
tenant.WithDefaultResolver(tenant.NewMultiResolver())

for _, tc := range []struct {
desc string
orgID string
Expand Down Expand Up @@ -110,8 +106,6 @@ func TestMultiTenantQuerier_SelectLogs(t *testing.T) {
}

func TestMultiTenantQuerier_SelectSamples(t *testing.T) {
tenant.WithDefaultResolver(tenant.NewMultiResolver())

for _, tc := range []struct {
desc string
orgID string
Expand Down Expand Up @@ -295,8 +289,6 @@ func TestMultiTenantQuerier_Label(t *testing.T) {
}
}

tenant.WithDefaultResolver(tenant.NewMultiResolver())

for _, tc := range []struct {
desc string
name string
Expand Down Expand Up @@ -354,8 +346,6 @@ func TestMultiTenantQuerier_Label(t *testing.T) {
}

func TestMultiTenantQuerierSeries(t *testing.T) {
tenant.WithDefaultResolver(tenant.NewMultiResolver())

for _, tc := range []struct {
desc string
orgID string
Expand Down Expand Up @@ -418,8 +408,6 @@ func TestMultiTenantQuerierSeries(t *testing.T) {
}

func TestVolume(t *testing.T) {
tenant.WithDefaultResolver(tenant.NewMultiResolver())

for _, tc := range []struct {
desc string
orgID string
Expand Down
6 changes: 6 additions & 0 deletions pkg/querier/querier_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"math"
"time"

"github.com/grafana/loki/pkg/logql/log"
Expand Down Expand Up @@ -454,6 +455,11 @@ func (r *readRingMock) GetInstanceState(_ string) (ring.InstanceState, error) {
return 0, nil
}

func (r *readRingMock) GetTokenRangesForInstance(_ string) (ring.TokenRanges, error) {
tr := ring.TokenRanges{0, math.MaxUint32}
return tr, nil
}

func mockReadRingWithOneActiveIngester() *readRingMock {
return newReadRingMock([]ring.InstanceDesc{
{Addr: "test", Timestamp: time.Now().UnixNano(), State: ring.ACTIVE, Tokens: []uint32{1, 2, 3}},
Expand Down
6 changes: 6 additions & 0 deletions pkg/util/ring/ring_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ring

import (
"math"
"testing"
"time"

Expand Down Expand Up @@ -89,6 +90,11 @@ func (r *readRingMock) GetInstanceState(_ string) (ring.InstanceState, error) {
return 0, nil
}

func (r *readRingMock) GetTokenRangesForInstance(_ string) (ring.TokenRanges, error) {
tr := ring.TokenRanges{0, math.MaxUint32}
return tr, nil
}

type readLifecyclerMock struct {
mock.Mock
addr string
Expand Down
1 change: 1 addition & 0 deletions tools/tsdb/bloom-tester/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"flag"
"fmt"

"github.com/grafana/loki/pkg/storage/bloom/v1/filter"
tsdbindex "github.com/grafana/loki/pkg/storage/stores/shipper/indexshipper/tsdb/index"

Expand Down
3 changes: 2 additions & 1 deletion tools/tsdb/bloom-tester/metrics.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
v1 "github.com/grafana/loki/pkg/storage/bloom/v1"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

v1 "github.com/grafana/loki/pkg/storage/bloom/v1"

"github.com/grafana/loki/pkg/storage/bloom/v1/filter"
)

Expand Down
3 changes: 2 additions & 1 deletion tools/tsdb/bloom-tester/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"context"
v1 "github.com/grafana/loki/pkg/storage/bloom/v1"
"math"
"time"

v1 "github.com/grafana/loki/pkg/storage/bloom/v1"

"github.com/prometheus/client_golang/prometheus/promauto"

"github.com/grafana/loki/pkg/util/constants"
Expand Down
37 changes: 37 additions & 0 deletions vendor/github.com/grafana/dskit/cancellation/error.go

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

29 changes: 23 additions & 6 deletions vendor/github.com/grafana/dskit/httpgrpc/server/server.go

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

Loading

0 comments on commit 6c4699d

Please sign in to comment.