loki: Attach the panic recovery handler on all HTTP handlers (#6780)

pull/7136/head
Periklis Tsirakidis 4 years ago committed by GitHub
parent ef97c1df2f
commit 630a491580
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 5
      pkg/loki/modules.go

@ -20,6 +20,7 @@
##### Fixes
* [6937](https://github.com/grafana/loki/pull/6937) **ssncferreira**: Fix topk and bottomk expressions with parameter <= 0.
* [6780](https://github.com/grafana/loki/pull/6780) **periklis**: Attach the panic recovery handler on all HTTP handlers
* [6358](https://github.com/grafana/loki/pull/6358) **taharah**: Fixes sigv4 authentication for the Ruler's remote write configuration by allowing both a global and per tenant configuration.
* [6375](https://github.com/grafana/loki/pull/6375) **dannykopping**: Fix bug that prevented users from using the `json` parser after a `line_format` pipeline stage.
* [6505](https://github.com/grafana/loki/pull/6375) **dmitri-lerko** Fixes `failed to receive pubsub messages` error with promtail GCPLog client.

@ -130,17 +130,20 @@ func (t *Loki) initServer() (services.Service, error) {
s := NewServerService(t.Server, servicesToWaitFor)
// Best effort to propagate the org ID from the start.
t.Server.HTTPServer.Handler = func(next http.Handler) http.Handler {
h := func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !t.Cfg.AuthEnabled {
next.ServeHTTP(w, r.WithContext(user.InjectOrgID(r.Context(), "fake")))
return
}
_, ctx, _ := user.ExtractOrgIDFromHTTPRequest(r)
next.ServeHTTP(w, r.WithContext(ctx))
})
}(t.Server.HTTPServer.Handler)
t.Server.HTTPServer.Handler = middleware.Merge(serverutil.RecoveryHTTPMiddleware).Wrap(h)
return s, nil
}

Loading…
Cancel
Save