Skip to content

Commit

Permalink
loki: Attach the panic recovery handler on all HTTP handlers (#6780)
Browse files Browse the repository at this point in the history
  • Loading branch information
periklis committed Sep 12, 2022
1 parent ef97c1d commit 630a491
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 630a491

Please sign in to comment.