From f7ffaee10d5b744cf74ea0119e904db9efc4b32a Mon Sep 17 00:00:00 2001 From: Mikhail Date: Sun, 30 Aug 2026 01:59:42 +0300 Subject: [PATCH] extend local medium readiness budget --- cmd/cognitive-worker/main.go | 11 ++++++----- cmd/core-runtime/main.go | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/cognitive-worker/main.go b/cmd/cognitive-worker/main.go index 2979f46..b3a020c 100644 --- a/cmd/cognitive-worker/main.go +++ b/cmd/cognitive-worker/main.go @@ -117,7 +117,8 @@ func main() { mux.Handle("/healthz", health.Handler{Runtime: "cognitive-worker", SemanticGeneration: 1, ArchitectureGeneration: 1}) readinessClient := &http.Client{Timeout: 2 * time.Second} cpuReadinessClient := &http.Client{Timeout: 10 * time.Second} - mediumReadinessClient := &http.Client{Timeout: 10 * time.Second} + mediumReadinessTimeout := 60 * time.Second + mediumReadinessClient := &http.Client{Timeout: mediumReadinessTimeout} lifeboatURL := strings.TrimSuffix(strings.TrimRight(envOr("LOCAL_LIFEBOAT_PROVIDER_URL", "http://cognitive-lifeboat:8086/v1"), "/"), "/v1") + "/health" fleetClient := &http.Client{Timeout: 2 * time.Second} preferredFleet := capability.FleetTier(envOr("COGNITIVE_PREFERRED_FLEET_TIER", string(capability.FleetTierFast))) @@ -138,11 +139,11 @@ func main() { if mediumAPIKey != "" { mediumHeaders["Authorization"] = "Bearer " + mediumAPIKey } - mediumHealthProbe = health.OptionalHTTPProbeWithHeaders(&http.Client{Timeout: 15 * time.Second}, mediumEndpoint, mediumHeaders) + mediumHealthProbe = health.OptionalHTTPProbeWithHeaders(mediumReadinessClient, mediumEndpoint, mediumHeaders) // The local gateway may need several seconds to enumerate a loaded model. // Keep this bounded, but do not classify a healthy MEDIUM provider as // unavailable before its authenticated discovery response can arrive. - mediumHealthProbe.Timeout = 15 * time.Second + mediumHealthProbe.Timeout = mediumReadinessTimeout } readinessProbes := []health.Probe{ health.HTTPProbe(readinessClient, strings.TrimRight(envOr("CORE_RUNTIME_URL", "http://core-runtime:8080"), "/")+"/healthz"), @@ -161,7 +162,7 @@ func main() { fleetEndpoints := []fleetEndpoint{ {ProviderID: "local-cpu-primary", ModelID: "local-cpu-model", Tier: capability.FleetTierFast, URL: cpuEndpoint, Headers: cpuFleetHeaders, Client: &http.Client{Timeout: 10 * time.Second}, Timeout: 2 * time.Second}, - {ProviderID: "local-medium-primary", ModelID: "local-medium-model", Tier: capability.FleetTierMedium, URL: mediumEndpoint, Headers: mediumHeaders, Client: mediumReadinessClient, Timeout: 15 * time.Second}, + {ProviderID: "local-medium-primary", ModelID: "local-medium-model", Tier: capability.FleetTierMedium, URL: mediumEndpoint, Headers: mediumHeaders, Client: mediumReadinessClient, Timeout: mediumReadinessTimeout}, {ProviderID: "cognitive-lifeboat", ModelID: "qwen3-8b-lifeboat", Tier: capability.FleetTierLifeboat, URL: lifeboatURL}, } if gpuConfigured { @@ -222,7 +223,7 @@ func refreshProviderDiscoveries(resolver bindingResolver, service discoveryServi for name := range service.providers { // Keep startup discovery bounded while allowing the authenticated local // gateway enough time to enumerate a loaded MEDIUM model. - ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) registration, ok := service.providers[name] if !ok || registration.Discovery == nil { cancel() diff --git a/cmd/core-runtime/main.go b/cmd/core-runtime/main.go index ddb0d27..9e1d0a1 100644 --- a/cmd/core-runtime/main.go +++ b/cmd/core-runtime/main.go @@ -154,10 +154,10 @@ func main() { } mux.Handle("/healthz", health.Handler{Runtime: "core-runtime", SemanticGeneration: 1, ArchitectureGeneration: 1}) readinessClient := &http.Client{Timeout: 2 * time.Second} - cognitiveReadinessClient := &http.Client{Timeout: 20 * time.Second} + cognitiveReadinessClient := &http.Client{Timeout: 70 * time.Second} cognitiveReadinessProbe := health.HTTPProbe(cognitiveReadinessClient, strings.TrimRight(envOr("COGNITIVE_RUNTIME_URL", "http://cognitive-worker:8083"), "/")+"/readyz") - cognitiveReadinessProbe.Timeout = 20 * time.Second - mux.Handle("/readyz", health.ReadinessHandler{Runtime: "core-runtime", Probes: []health.Probe{ + cognitiveReadinessProbe.Timeout = 70 * time.Second + mux.Handle("/readyz", health.ReadinessHandler{Runtime: "core-runtime", Timeout: 75 * time.Second, Probes: []health.Probe{ health.TCPProbe("postgres", envOr("POSTGRES_HOST", "postgres"), envOr("POSTGRES_PORT", "5432")), health.HTTPProbe(readinessClient, strings.TrimRight(envOr("CONTINUITY_RUNTIME_URL", "http://continuity-runtime:8081"), "/")+"/healthz"), // A running worker is not necessarily ready to serve cognitive traffic.