grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
23.51k stars 3.4k forks source link

chore: [k207] fix: Init internal server log along with loki's server instance #13256

Closed grafanabot closed 3 months ago

grafanabot commented 3 months ago

Backport 66b8c9b7738acd0e0616b88d35cf3ddc0df83e7e from #13221


What this PR does / why we need it: Currently Loki's internal server instance is running by default in a panic: nil pointer dereference because along all the updates for 3.0.0, we missed to initialize this server properly:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x84a4ff]

goroutine 1 [running]:
github.com/go-kit/log/level.NewFilter(...)
    /src/loki/vendor/github.com/go-kit/log/level/level.go:43
github.com/grafana/dskit/log.NewGoKitWithLevel({{0x0?, 0xc00192c208?}, 0x0?}, {0x0, 0x0})
    /src/loki/vendor/github.com/grafana/dskit/log/gokit.go:34 +0x21f
github.com/grafana/dskit/server.newServer({{0x0, 0x0}, 0x0, {0x2a68ab9, 0x3}, {0x0, 0x0}, 0xc1d, 0x0, {0x0, ...}, ...}, ...)
    /src/loki/vendor/github.com/grafana/dskit/server/server.go:254 +0x67
github.com/grafana/dskit/server.New({{0x0, 0x0}, 0x0, {0x2a68ab9, 0x3}, {0x0, 0x0}, 0xc1d, 0x0, {0x0, ...}, ...})
    /src/loki/vendor/github.com/grafana/dskit/server/server.go:241 +0x5f
github.com/grafana/loki/v3/pkg/loki.(*Loki).initInternalServer(0xc000d46000)
    /src/loki/pkg/loki/modules.go:213 +0xb8
github.com/grafana/dskit/modules.(*Manager).initModule(0xc000150e40, {0x7ffdd3022ccb, 0xd}, 0x1?, 0xc0008f88d0?)
    /src/loki/vendor/github.com/grafana/dskit/modules/modules.go:136 +0x1f7
github.com/grafana/dskit/modules.(*Manager).InitModuleServices(0x0?, {0xc000e8dca0, 0x1, 0xc0008e8660?})
    /src/loki/vendor/github.com/grafana/dskit/modules/modules.go:108 +0xd8
github.com/grafana/loki/v3/pkg/loki.(*Loki).Run(0xc000d46000, {0x0?, {0x4?, 0x3?, 0x4912940?}})
    /src/loki/pkg/loki/loki.go:453 +0x9d
main.main()
    /src/loki/cmd/loki/main.go:122 +0x113b

Which issue(s) this PR fixes: Fixes #

Special notes for your reviewer:

The internal server in Loki is mainly used in mTLS setups on Kubernetes where we want to allow TLS-secured Readiness/Liveness-Checks without client certificates. Usually k8s readiness/liveness checks do not support mTLS.

Checklist