fix(api): report a page as degraded unless every component is down
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
4d1db0943e
commit
e6c3deb54d
2 files changed
+13
-4
No files matched your search
@@ -98,7 +98,7 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
|
||||
}
|
||||
names := map[uuid.UUID]string{}
|
||||
worst := agentapi.PageOperational
|
||||
allUnknown := true
|
||||
allUnknown, allDown := true, len(listed) > 0
|
||||
for _, m := range listed {
|
||||
name := m.Label
|
||||
if name == "" {
|
||||
@@ -119,6 +119,9 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
|
||||
if comp.Status != agentapi.PageUnknown {
|
||||
allUnknown = false
|
||||
}
|
||||
if comp.Status != agentapi.PageOutage {
|
||||
allDown = false
|
||||
}
|
||||
worst = worse(worst, comp.Status)
|
||||
if n := len(snap.Sections); n == 0 || snap.Sections[n-1].Name != m.Section {
|
||||
snap.Sections = append(snap.Sections, agentapi.Section{Name: m.Section})
|
||||
@@ -126,9 +129,14 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
|
||||
last := &snap.Sections[len(snap.Sections)-1]
|
||||
last.Components = append(last.Components, comp)
|
||||
}
|
||||
// A single failed component is a partial problem; only a complete
|
||||
// failure is reported as an outage of the whole page.
|
||||
snap.Status = worst
|
||||
if allUnknown {
|
||||
switch {
|
||||
case allUnknown:
|
||||
snap.Status = agentapi.PageUnknown
|
||||
case worst == agentapi.PageOutage && !allDown:
|
||||
snap.Status = agentapi.PageDegraded
|
||||
}
|
||||
for _, i := range incidents {
|
||||
snap.Incidents = append(snap.Incidents, agentapi.PageIncident{Component: names[i.MonitorID], StartedAt: i.StartedAt, ResolvedAt: i.ResolvedAt})
|
||||
|
||||
Reference in new issue
Block a user