Skip to content

Commit

Permalink
Fix internal server bootstrap for query frontend (grafana#7328)
Browse files Browse the repository at this point in the history
Adds a fix for setting up the internal server module
  • Loading branch information
periklis authored and changhyuni committed Nov 8, 2022
1 parent 5e84fdb commit e54c14a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
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

0 comments on commit e54c14a

Please sign in to comment.