feat: maintenance windows and Markdown descriptions
Monitors and groups get one-off or recurring maintenance. While it is in progress, failures neither open incidents nor alert, so the SLA is not affected; successes still resolve earlier incidents. The console shows monitors under maintenance and lists windows on a new page and on monitor pages. Status pages announce maintenance in progress and planned for the next two weeks and mark affected components; the occurrences are part of the snapshot and evaluated when the page is shown, so this also works from cache during an API outage. Maintenance and status page descriptions are rendered as Markdown. Closes #71 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
259b3b8e05
commit
43b0a35f20
28 files changed
+3918
-894
No files matched your search
@@ -231,7 +231,7 @@ func (s *Server) serve(c *gin.Context) {
|
||||
}
|
||||
s.localizeRequest(c)
|
||||
c.Header("Cache-Control", "public, max-age=30")
|
||||
web.Render(c, http.StatusOK, web.PublicStatusPage(e.Snap, web.PublicAssets{CSSHref: "/static/dist/app.css", StaleSince: staleSince, LegalBase: base}))
|
||||
web.Render(c, http.StatusOK, web.PublicStatusPage(e.Snap.WithMaintenance(s.now()), web.PublicAssets{CSSHref: "/static/dist/app.css", StaleSince: staleSince, LegalBase: base, Now: s.now()}))
|
||||
}
|
||||
|
||||
// serveLegal shows a legal document of the page from the cached snapshot,
|
||||
|
||||
@@ -264,3 +264,38 @@ func TestLegalDocuments(t *testing.T) {
|
||||
t.Errorf("unknown document = %d, want 404", code)
|
||||
}
|
||||
}
|
||||
|
||||
// Maintenance in a cached snapshot starts on time even without the API.
|
||||
func TestMaintenanceStartsWhileAPIIsDown(t *testing.T) {
|
||||
now := time.Now()
|
||||
src := newSource()
|
||||
src.pages["|acme"] = agentapi.PageSnapshot{
|
||||
Title: "Acme status", Status: agentapi.PageOperational, Description: "Run by **Acme**",
|
||||
Sections: []agentapi.Section{{Components: []agentapi.Component{{Name: "Database", Status: agentapi.PageOperational}, {Name: "Web", Status: agentapi.PageOperational}}}},
|
||||
Maintenance: []agentapi.PageMaintenance{{
|
||||
Title: "DB upgrade", Description: "Expect <b>short</b> _gaps_.", Components: []string{"Database"},
|
||||
Start: now.Add(30 * time.Minute), End: now.Add(90 * time.Minute),
|
||||
}},
|
||||
}
|
||||
h := newHarness(t, src, t.TempDir(), &now)
|
||||
_, page := h.get("status.example.test", "/acme")
|
||||
if !strings.Contains(page, "Geplante Wartung") || strings.Contains(page, "Laufende Wartung") {
|
||||
t.Error("upcoming maintenance is not announced as planned")
|
||||
}
|
||||
if !strings.Contains(page, "<strong>Acme</strong>") || !strings.Contains(page, "<em>gaps</em>") || strings.Contains(page, "<b>short</b>") {
|
||||
t.Error("descriptions are not rendered as safe Markdown")
|
||||
}
|
||||
|
||||
src.mu.Lock()
|
||||
src.err = errors.New("connection refused")
|
||||
src.mu.Unlock()
|
||||
now = now.Add(45 * time.Minute)
|
||||
_, page = h.get("status.example.test", "/acme")
|
||||
if !strings.Contains(page, "Laufende Wartung") || !strings.Contains(page, "Geplante Wartung läuft") {
|
||||
t.Error("maintenance in progress is not shown from the cache")
|
||||
}
|
||||
now = now.Add(time.Hour)
|
||||
if _, page = h.get("status.example.test", "/acme"); strings.Contains(page, "Wartung") {
|
||||
t.Error("ended maintenance is still shown")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user