Skip to content
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

Fix internal server bootstrap for query frontend #7328

Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* [7270](https://github.com/grafana/loki/pull/7270) **wilfriedroset**: Add support for `username` to redis cache configuration.

##### Fixes
* [7238](https://github.com/grafana/loki/pull/7328) **periklis**: Fix internal server bootstrap for query frontend
* [7288](https://github.com/grafana/loki/pull/7288) **ssncferreira**: Fix query mapping in AST mapper `rangemapper` to support the new `VectorExpr` expression.
* [7040](https://github.com/grafana/loki/pull/7040) **bakunowski**: Remove duplicated `loki_boltdb_shipper` prefix from `tables_upload_operation_total` metric.
* [6937](https://github.com/grafana/loki/pull/6937) **ssncferreira**: Fix topk and bottomk expressions with parameter <= 0.
Expand Down
8 changes: 4 additions & 4 deletions pkg/loki/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type Config struct {
BallastBytes int `yaml:"ballast_bytes"`

// TODO(dannyk): Remove these config options before next release; they don't need to be configurable.
// These are only here to allow us to test the new functionality.
// These are only here to allow us to test the new functionality.
UseBufferedLogger bool `yaml:"use_buffered_logger"`
UseSyncLogger bool `yaml:"use_sync_logger"`

Expand Down Expand Up @@ -570,7 +570,7 @@ func (t *Loki) setupModuleManager() error {
}

if t.Cfg.InternalServer.Enable {
depsToUpdate := []string{Distributor, Ingester, Querier, QueryFrontend, QueryScheduler, Ruler, TableManager, Compactor, IndexGateway}
depsToUpdate := []string{Distributor, Ingester, Querier, QueryFrontendTripperware, QueryScheduler, Ruler, TableManager, Compactor, IndexGateway}

for _, dep := range depsToUpdate {
var idx int
Expand All @@ -581,8 +581,8 @@ func (t *Loki) setupModuleManager() error {
}
}

lhs := deps[dep][0:idx]
rhs := deps[dep][idx+1:]
lhs := deps[dep][0 : idx+1]
rhs := deps[dep][idx+2:]

deps[dep] = append(lhs, InternalServer)
deps[dep] = append(deps[dep], rhs...)
Expand Down
37 changes: 34 additions & 3 deletions pkg/loki/loki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,55 @@ func TestLoki_isModuleEnabled(t1 *testing.T) {
}

func TestLoki_AppendOptionalInternalServer(t *testing.T) {
tests := []string{Distributor, Ingester, Querier, QueryFrontend, QueryScheduler, Ruler, TableManager, Compactor, IndexGateway}
fake := &Loki{
Cfg: Config{
Target: flagext.StringSliceCSV{All},
Server: server.Config{
HTTPListenAddress: "3100",
},
},
}
err := fake.setupModuleManager()
assert.NoError(t, err)

var tests []string
for target, deps := range fake.deps {
switch target {
// Blacklist these targets for using the internal server
case IndexGatewayRing, MemberlistKV, OverridesExporter, Ring, Embededcache, Server:
continue
}

for _, dep := range deps {
if dep == Server {
tests = append(tests, target)
break
}
}
}

assert.NotEmpty(t, tests, tests)

for _, tt := range tests {
t.Run(tt, func(t *testing.T) {
l := &Loki{
Cfg: Config{
Target: flagext.StringSliceCSV{tt},
Server: server.Config{
HTTPListenAddress: "3100",
},
InternalServer: internalserver.Config{
Config: server.Config{
HTTPListenAddress: "3002",
HTTPListenAddress: "3101",
},
Enable: true,
},
},
}

err := l.setupModuleManager()
assert.NoError(t, err)
assert.Contains(t, l.deps[tt], InternalServer)
assert.Contains(t, l.deps[tt], Server)
})
}
}
Expand Down