From 22d85ce646a554c5dfcb38ec78f54eb6a4628689 Mon Sep 17 00:00:00 2001 From: Grendgi Date: Wed, 17 Jun 2026 16:34:44 +0300 Subject: [PATCH] fix: align ai health status contract --- internal/httpapi/health.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/httpapi/health.go b/internal/httpapi/health.go index 50fd634..99822f6 100644 --- a/internal/httpapi/health.go +++ b/internal/httpapi/health.go @@ -28,30 +28,30 @@ func (s *Server) handleHealthDetail(w http.ResponseWriter, r *http.Request) { defer cancel() resp := healthDetailResponse{ - Status: "healthy", + Status: "ok", Generated: time.Now().UTC(), } if err := s.store.Ping(ctx); err != nil { resp.Components = append(resp.Components, healthComponent{ Name: "postgres", - Status: "unhealthy", + Status: "down", Message: err.Error(), }) - resp.Status = worseHealthStatus(resp.Status, "unhealthy") + resp.Status = worseHealthStatus(resp.Status, "down") writeJSON(w, http.StatusServiceUnavailable, resp) return } - resp.Components = append(resp.Components, healthComponent{Name: "postgres", Status: "healthy"}) + resp.Components = append(resp.Components, healthComponent{Name: "postgres", Status: "ok"}) stats, err := s.store.Stats(ctx, s.cfg.WorkerLeaseTimeout) if err != nil { resp.Components = append(resp.Components, healthComponent{ Name: "queue", - Status: "unhealthy", + Status: "down", Message: err.Error(), }) - resp.Status = worseHealthStatus(resp.Status, "unhealthy") + resp.Status = worseHealthStatus(resp.Status, "down") writeJSON(w, http.StatusServiceUnavailable, resp) return } @@ -68,7 +68,7 @@ func (s *Server) handleHealthDetail(w http.ResponseWriter, r *http.Request) { } statusCode := http.StatusOK - if resp.Status == "unhealthy" { + if resp.Status == "down" { statusCode = http.StatusServiceUnavailable } writeJSON(w, statusCode, resp) @@ -79,7 +79,7 @@ func (s *Server) healthProviders(ctx context.Context) healthComponent { s.checkLLM(ctx), s.checkAudioLLM(ctx, transcription.ProviderWhisperLargeV3, s.cfg.AudioBaseURL, s.cfg.AudioAPIKey, s.cfg.AudioModel, s.cfg.AudioTimeout), } - status := "healthy" + status := "ok" messages := make([]string, 0) for _, provider := range providers { switch { @@ -87,7 +87,7 @@ func (s *Server) healthProviders(ctx context.Context) healthComponent { status = worseHealthStatus(status, "degraded") messages = append(messages, provider.Name+" not configured") case !provider.OK: - status = worseHealthStatus(status, "unhealthy") + status = worseHealthStatus(status, "down") if provider.Error != "" { messages = append(messages, provider.Name+": "+provider.Error) } else { @@ -124,7 +124,7 @@ func healthQueue(stats *model.Stats) healthComponent { oldestRunningAgeSeconds = row.OldestRunningAgeSeconds } } - status := "healthy" + status := "ok" message := "" if staleRunning > 0 { status = "degraded" @@ -153,7 +153,7 @@ func healthErrors(stats *model.Stats) healthComponent { failedTotal += row.Total failed24h += row.Last24h } - status := "healthy" + status := "ok" message := "" if failed24h > 0 { status = "degraded" @@ -194,7 +194,7 @@ func healthThroughput(stats *model.Stats) healthComponent { } } - status := "healthy" + status := "ok" message := "" if len(stuckStages) > 0 { status = "degraded" @@ -214,7 +214,7 @@ func healthThroughput(stats *model.Stats) healthComponent { } func healthInfra(infra infraStatusResponse) healthComponent { - status := "healthy" + status := "ok" message := "" if infra.SidecarError != "" { status = "degraded" @@ -231,11 +231,11 @@ func healthInfra(infra infraStatusResponse) healthComponent { } func worseHealthStatus(current, next string) string { - if current == "unhealthy" || next == "unhealthy" { - return "unhealthy" + if current == "down" || next == "down" { + return "down" } if current == "degraded" || next == "degraded" { return "degraded" } - return "healthy" + return "ok" }