diff --git a/cmd/alertmanager/main.go b/cmd/alertmanager/main.go index e22a8134..0957c049 100644 --- a/cmd/alertmanager/main.go +++ b/cmd/alertmanager/main.go @@ -345,7 +345,7 @@ func main() { router = router.WithPrefix(*routePrefix) } - webReload := make(chan struct{}) + webReload := make(chan chan error) ui.Register(router, webReload, logger) @@ -367,9 +367,10 @@ func main() { for { select { case <-hup: - case <-webReload: + reload() + case errc := <-webReload: + errc <- reload() } - reload() } }() diff --git a/ui/web.go b/ui/web.go index 321a92e9..5f17ef2c 100644 --- a/ui/web.go +++ b/ui/web.go @@ -48,7 +48,7 @@ func serveAsset(w http.ResponseWriter, req *http.Request, fp string, logger log. } // Register registers handlers to serve files for the web interface. -func Register(r *route.Router, reloadCh chan<- struct{}, logger log.Logger) { +func Register(r *route.Router, reloadCh chan<- chan error, logger log.Logger) { ihf := prometheus.InstrumentHandlerFunc r.Get("/metrics", prometheus.Handler().ServeHTTP) @@ -73,8 +73,13 @@ func Register(r *route.Router, reloadCh chan<- struct{}, logger log.Logger) { )) r.Post("/-/reload", func(w http.ResponseWriter, req *http.Request) { - w.Write([]byte("Reloading configuration file...")) - reloadCh <- struct{}{} + errc := make(chan error) + defer close(errc) + + reloadCh <- errc + if err := <-errc; err != nil { + http.Error(w, fmt.Sprintf("failed to reload config: %s", err), http.StatusInternalServerError) + } }) r.Get("/-/healthy", func(w http.ResponseWriter, _ *http.Request) {