Skip to content

Commit

Permalink
Add an error log when the config fails to reload (#6283)
Browse files Browse the repository at this point in the history
Co-authored-by: Paulin Todev <[email protected]>
Co-authored-by: Paschalis Tsilias <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2024
1 parent 18fe885 commit baebed5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Main (unreleased)

- Mutex and block pprofs are now available via the pprof endpoint. (@mattdurham)

- Added an error log when the config fails to reload. (@kurczynski)

- Added additional http client proxy configurations to components for
`no_proxy`, `proxy_from_environment`, and `proxy_connect_header`. (@erikbaranowski)

Expand Down
6 changes: 4 additions & 2 deletions service/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,16 @@ func (s *Service) Run(ctx context.Context, host service.Host) error {
if s.opts.ReloadFunc != nil {
r.HandleFunc("/-/reload", func(w http.ResponseWriter, _ *http.Request) {
level.Info(s.log).Log("msg", "reload requested via /-/reload endpoint")
defer level.Info(s.log).Log("msg", "config reloaded")

_, err := s.opts.ReloadFunc()
if err != nil {
level.Error(s.log).Log("msg", "failed to reload config", "err", err.Error())
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
fmt.Fprintln(w, "config reloaded")

level.Info(s.log).Log("msg", "config reloaded")
_, _ = fmt.Fprintln(w, "config reloaded")
}).Methods(http.MethodGet, http.MethodPost)
}

Expand Down

0 comments on commit baebed5

Please sign in to comment.