aboutsummaryrefslogtreecommitdiff
path: root/setup/base
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-10-04 13:02:41 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-10-04 13:02:41 +0100
commit3da182212e86daca1d7019efbd424b2bd38b8b3c (patch)
tree3d3e4b7d52e03f69aa352aa57f04f904160c71bb /setup/base
parenta767102f8a74031b5d0612d985c7589dfe0e0821 (diff)
Track reasons why the process is in a degraded state
Diffstat (limited to 'setup/base')
-rw-r--r--setup/base/base.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/setup/base/base.go b/setup/base/base.go
index 0636c7b8..2e3a3a19 100644
--- a/setup/base/base.go
+++ b/setup/base/base.go
@@ -18,6 +18,7 @@ import (
"context"
"crypto/tls"
"database/sql"
+ "encoding/json"
"fmt"
"io"
"net"
@@ -467,8 +468,13 @@ func (b *BaseDendrite) SetupAndServeHTTP(
w.WriteHeader(200)
})
b.DendriteAdminMux.HandleFunc("/monitor/health", func(w http.ResponseWriter, r *http.Request) {
- if b.ProcessContext.IsDegraded() {
+ if isDegraded, reasons := b.ProcessContext.IsDegraded(); isDegraded {
w.WriteHeader(503)
+ _ = json.NewEncoder(w).Encode(struct {
+ Warnings []string `json:"warnings"`
+ }{
+ Warnings: reasons,
+ })
return
}
w.WriteHeader(200)